Welcome Guest | Sign in | Register
Inheritance - Discussion Page For Q.2847 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Inheritance > Questions and Answers

Q: class A{
A(){
System.out.println(1);
} }
Class B extends A{
B(){
System.out.println(2);
}}
Class C extends B {
C(){
System.out.println(3);
Super();
} }

Class Manager{
Public static void main(String args[]){
C c=new C();
} }
A. 1,2,20 B. 20,2,1
C. compile time error D. run time error

Answer and Explanation

Answer:compile time error

Explanation:
in main() method we are creating an object of class C by using C class constructor, in class C constructor super() keyword is there in second statement, but according to the rule super () must be in the first statement in the constructor body , so it will throw compile time error.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.