Menu
Topics Index
...
`

Abstract Classes Correct Statement


If you need explanation Read this topic

If you need Answer Take test on this topic

Abstract Classes Correct Statement
Suppose A is an abstract class, B is a concrete subclass of A, and both A and B have a default constructor. Which of the following is correct?
A. A a = new A();
B. A a = new B();
C. B b = new B();
D. Both B & C
E. Both A & C
Topic: Java Abstract Class

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 D

An abstract class is a class that is declared abstract—it may or may
not include abstract methods. Abstract classes cannot be instantiated,
but they can be subclassed.

An abstract method is a method that is declared without an
implementation (without braces, and followed by a semicolon), like
this:

abstract void moveTo(double deltaX, double deltaY);

When an abstract class is subclassed, the subclass usually provides
implementations for all of the abstract methods in its parent class.
However, if it does not, then the subclass must also be declared
abstract.

Program Execution:

Here,if we create instance of class A and assign it the object of B it
is valid and it will call first the constructor of A and then B.

Also,if we create object of B it is also valid,and it will call first
the constructor of A and then B.

So,both B and C are correct.
ANS IS D

Posted by Mânïshå Mùlchåndânï    2015-03-10 10:28:51


This dose is now closed and the winners are Mânïshå Mùlchåndânï,  for 'First Correct Comment', Mânïshå Mùlchåndânï,  for 'Best Comment' and Mânïshå Mùlchåndânï for the 'Popular Comment'. The 'lucky liker' is Mânïshå Mùlchåndânï. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2015-03-11 01:30:54


© meritcampus 2019

All Rights Reserved.

Open In App