Multiple choice technology programming languages

interface my_interface{ public void show(); } public class test08 { public static void main(String[] args) { my_interface mi = new B(); mi.show(); } } class A implements my_interface{ public void show(){ System.out.println("This is implemented method "); } } class B extends A{ public void show(){ System.out.println("This is overrided method "); } } What is the output

  1. This is implemented method

  2. This is overrided method

  3. Compile time Error

  4. Run time error

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is Java polymorphism in action. The interface reference 'mi' points to an object of class B. At runtime, the JVM calls the overridden show() method in class B, not the one in class A. This demonstrates dynamic method dispatch - the actual method executed depends on the object type, not the reference type.