Topics Index

Abstract Classes655

If you need explanation Read this topic

If you need Answer Take test on this topic

Abstract Classes655
Which of the following classes fail to compile?
class X { }
abstract class Y { }
class Z { abstract void method(); }

A. X
B. X, Y, Z
C. Y
D. Z
E. All classes compile
Topic: Rules For Abstract Methods and Abstract Classes

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.

Ans is we have the abstract class concept..abstract class means a class contains incomplete methods(abstract method which dont have method defination)..for abstract class we can not create the instance for it but we can create the reference for it...and abstract class can have the constructors and can be extended..if a class have an abstract method than we must write that class as abstract otherwise error will raise..even if a class does not contains abstract methods we can make it as abstract.
here class X has abstract methods so no problem..
class y made as abstract but did not contain any abstract methods so here no problem

* class z has abstract method but did not write class as abstract so here compiler will raise an error

Posted by Uday Kumar    2015-02-11 03:50:09


Posted by Shubham Bansal    2015-02-11 06:14:30

Ans is D as the class containing abstract methods is defined  with the abstract keyword .abstract method is defined as the method which donot contain any body..therefore class z should be defined as abstract sothat the class will compile

Posted by Ramya Reddy Addulla    2015-02-11 12:15:53

This dose is now closed and the winners are Uday Kumar,  for 'First Correct Comment', Uday Kumar,  for 'Best Comment' and Uday Kumar for the 'Popular Comment'. The 'lucky liker' is Sai Ram. Please login into Merit Campus using facebook, to claim your recharge. Go to to raise the recharge.

Posted by Merit Campus    2015-02-12 04:43:12

© meritcampus 2019

All Rights Reserved.

Open In App