Home » JAVA Programming » Inheritance » Question
  1. Which two classes use the Shape class correctly?

    A. public class Circle implements Shape
    {
    private int radius;
    }

    B. public abstract class Circle extends Shape
    {
    private int radius;
    }

    C. public class Circle extends Shape
    {
    private int radius;
    public void draw();
    }

    D. public abstract class Circle implements Shape
    {
    private int radius;
    public void draw();
    }

    E. public class Circle extends Shape
    {
    private int radius;
    public void draw()
    {
    /* code here */
    }
    }

    F. public abstract class Circle implements Shape
    {
    private int radius;
    public void draw()
    {
    /* code here */
    }
    }
    1. C,E
    2. T,H
    3. A,C
    4. B,E
    5. None of these
Correct Option: D

If one is extending any class, then they should use extends keyword not implements.



Your comments will be displayed only after manual approval.