MCQ Single Best Answer Not Set

QDetermine output:
class A{
	public void method1(){
		System.out.print("Class A method1");
	}
}
class B extends A{
	public void method2(){
		System.out.print("Class B method2");
	}
}
class C extends B{
	public void method2(){
		System.out.print("Class C method2");
	}	
	public void method3(){
		System.out.print("Class C method3");
	}
}
public class Test{
	public static void main(String args[]){
		A a = new A();
		C c = new C();		
		c.method2();
		a = c;
		a.method3();
	}
}

ID: #2258 Inheritance in Java MCQ 2,262 views
Question Info
#2258Q ID
Not SetDifficulty
Inheritance in Java MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A Class B method2 Class C method3
  • B Class C method2 Class C method3
  • C Compilation Error
  • D Runtime exception
Correct Answer: Option C

Explanation

Compilation Error

Share This Question

Challenge a friend or share with your study group.