Question discussion

What will be the output?interface A{ public void method();}class One{ public void method(){ System.out.println("Class One method"); }}class…

291566Medium 1 reply 1,261 views
27
What will be the output?interface A{ public void method();}class One{ public void method(){ System.out.println("Class One method"); }}class Two extends One implements A{ public void method(){ System.out.println("Class Two method"); }}public class Test extends Two{ public static void main(String[] args){ A a = new Two(); a.method(); }}
  • Awill print Class One method
  • Bwill print Class Two method
  • Ccompiles fine but print nothing
  • DCompilation Error
  • ENone of these
Correct answer: B

Discussion 1

0
CCommunity
will print Class Two method