Q. 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) Class Two method1 D. Throws a NoSuchMethodException at runtime.
πŸ’¬ Discuss
βœ… Correct Answer: (C) Class Two method1

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
143
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Vikash Gupta
Publisher
πŸ“ˆ
86%
Success Rate