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. Compilation Error

B. Class One method1

C. Class Two method1

D. Throws a NoSuchMethodException at runtime.

E. None of these

Answer: Option C


This Question Belongs to Java Program >> Inheritence

Join The Discussion

Comments ( 1 )

  1. Shrey Soni
    Shrey Soni :
    7 years ago

    In case of inheritance ever there is parent method is present the child class prefers its own method due to method overriding.

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