About 249,000 results
Open links in new tab
  1. Java Polymorphism - Shape Class with Circle, Rectangle, and …

    Apr 28, 2025 · Java Polymorphism Exercises, Practice, Solution - Explore Java polymorphism by creating a Shape base class with Circle, Rectangle, and Triangle subclasses. Each subclass overrides the calculateArea() method to calculate and return the area of the respective shape.

  2. Draw shapes example - Java Code Geeks

    Nov 11, 2012 · Basically, all you have to do in order to draw shapes in a Java application is: Create a new Frame. Create a class that extends the Component class and override the paint method. Use Graphics2D.drawLine to draw a simple line. Use Graphics2D.drawOval to draw an oval shape in the screen. Use Graphics2D.drawRect to draw a rectangle on the screen.

  3. Shape (Java Platform SE 8 ) - Oracle

    The Shape interface provides definitions for objects that represent some form of geometric shape. The Shape is described by a PathIterator object, which can express the outline of the Shape as well as a rule for determining how the outline divides the 2D plane into interior and exterior points.

  4. Creating basic shapes example - Java Code Geeks

    Nov 11, 2012 · Basically to create simple shapes in Java: Use Line2D, Ellipse2D, Rectangle2D, RoundRectangle2D, Arc2D, Area to create some simple shapes; Then use Graphics2D class and its draw function ton paint each shape an a new Frame. Let’s see how the code looks like:

  5. Java Program to Implement Shape Interface using Circle and …

    This is a Java Program to Make Shape as an Interface and Implement it using Circle and Rectangle Class. Interfaces are syntactically similar to classes, but they lack instance variables, and their methods are declared without any body.

  6. Drawing Geometric Primitives (The Java™ Tutorials > 2D Graphics ...

    Java Tutorials lesson shows how to use the Graphics2D class to draw graphic primitives, arbitrary shapes, and to display graphics with outline and fill styles

  7. Java - Abstract Shape Class with Circle and Triangle Subclasses

    Apr 28, 2025 · Write a Java program to create an abstract class Shape with abstract methods calculateArea() and calculatePerimeter(). Create subclasses Circle and Triangle that extend the Shape class and implement the respective methods …

  8. Java - Shape with the getArea() method - w3resource

    Apr 28, 2025 · Write a Java program to create an interface Shape with the getArea () method. Create three classes Rectangle, Circle, and Triangle that implement the Shape interface. Implement the getArea () method for each of the three classes. Sample Solution: Java Code: // This is an interface named 'Shape' that defines a contract for classes to implement.

  9. Shapes OO Example: Java Code - The Trek BBS

    // create some shape instances. Shape scribble[] = new Shape[2]; scribble[0] = new Rectangle(10, 20, 5, 6); scribble[1] = new Circle(15, 25, 8); // iterate through the list and handle shapes polymorphically. for (int i = 0; i < scribble.length; i++) { scribble[i].draw(); scribble[i].rMoveTo(100, 100); scribble[i].draw();

  10. java - Object oriented design - Shapes - Stack Overflow

    Jun 11, 2018 · Implement an objected oriented solution for creating the following shapes: Ellipse, Circle, Square, Rectangle, Triangle, Parallelogram. Each shape created must have the following parameters: unique id, color. And following functions: color change, move, area, circumference, is …

  11. Some results have been removed
Refresh