ExamVeda
Login
Home
This question belongs to Java Program Inheritence
Inheritence
?

What is the output of the following program code?
abstract class C1{
	public C1(){ 
		System.out.print(1); 
	} 
} 
class C2 extends C1{ 
	public C2(){ 
		System.out.print(2); 
	} 
} 
class C3 extends C2{ 
	public C3(){ 
		System.out.println(3); 
	} 
} 
public class Test{ 
	public static void main(String[] a){ 
		new C3(); 
	} 
}

Answer & Solution
Correct Answer: Option C
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

2 Comments
GAUTAM KUMAR
GAUTAM KUMAR 4 years ago
Because every constructor in java calls super() method by default, and it runs the parent constructor.
Sharanu Koti
Sharanu Koti 9 years ago
how this answer came?