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

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

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

Join the Discussion

1 Comment
Shrey Soni
Shrey Soni 10 years ago
In case of inheritance ever there is parent method is present the child class prefers its own method due to method overriding.