Examveda
Examveda

What will be the output?
interface A{
	public void method1();
}
class One implements A{
	public void method1(){
		System.out.println("Class One method1");
	}
}
class Two extends One{
	public void method1(){
		System.out.println("Class Two method1");
	}
}
public class Test extends Two{
	public static void main(String[] args){
		A a = new Two();
		a.method1();
	}
}

A. Class One method1

B. Class Two method1

C. Nothing will be printed

D. Compilation Error

Answer: Option B


This Question Belongs to Java Program >> Overriding And Overloading

Join The Discussion

Comments ( 1 )

  1. Sai Kumar
    Sai Kumar :
    6 years ago

    as the child object is used to call the method, the method METHOD1 present in child class will be executed

Related Questions on Overriding and Overloading