LogiQuest
Back to Inheritance and Polymorphism
11

What is the output of the following program?

public class Main {
    public static void main(String[] args) {
        A a = new B();
        System.out.println(a.s());
    }
}
class A { static String s() { return "A"; } }
class B extends A { static String s() { return "B"; } }
Hard

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.