Examveda
Examveda

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(); 
	} 
}

A. 12

B. 23

C. 123

D. 321

Answer: Option C


This Question Belongs to Java Program >> Inheritence

Join The Discussion

Comments ( 2 )

  1. GAUTAM KUMAR
    GAUTAM KUMAR :
    1 year ago

    Because every constructor in java calls super() method by default, and it runs the parent constructor.

  2. Sharanu Koti
    Sharanu Koti :
    6 years ago

    how this answer came?

Related Questions on Inheritence

What is inheritance in Java?

A. The process of acquiring properties and behaviors of one class by another

B. The process of creating objects

C. The process of encapsulation

D. The process of overloading methods