Topics Index

Abstract Class1895

If you need explanation Read this topic

If you need Answer Take test on this topic

Abstract Class1895
Which of the following class have used the Shape class correctly?
public abstract class Shape {
    public abstract void draw();

    "Insert code here"


A. <cl>public abstract class Triangle extends Shape {
    private int side;
B. <cl>public abstract class Triangle implements Shape {
    public void draw() {
C. <cl>public class Triangle extends Shape {
    public void draw();
D. None of the above
Topic: Java Access Modifiers With Example Program

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

c is the answer here we extend the abstract class and give the definition of the method draw().

Posted by Karteek Paruchuri    2013-11-04 08:54:26

ans must be A as Shape is a class it should be extended by another cls.. b is incoreect bcoz implements shape and C is rong bcoz no definition for draw method

Posted by Pramod Jain    2013-11-04 08:54:35

Ans:A. The correct answer would be a class which extends Shape and defines draw() or an abstract class which extends Shape and doesnt provide definition of draw(). option A matches the second criteria.Option c just declares draw().

Posted by Priyanka Madiraju    2013-11-04 09:07:30

ans A: because  triangle class extends shape but it is not providing the implementaton of the function draw() so defining the class as abstract where as optiob b is implementing draw() and defined as  abstract which is wrong and option c is violating in its definitions and declarations.

Posted by Manasa Jyothi Sree    2013-11-04 10:17:54

Ans:D.  The given class is abstract class i.e. Shape and it's having abstract method i.e. draw(). The draw() is abstract method so it has to be define in sub class. in c draw() method must be define.

Posted by Rambabu Sri    2013-11-04 10:31:03


Posted by Gopinath Manchikanti    2013-11-04 11:07:07

Congratulations Pramod Jain. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2013-11-05 03:23:22

© meritcampus 2019

All Rights Reserved.

Open In App