LogiQuest
Back to Inheritance and Polymorphism
15

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.get());
    }
}
class A { String get() { return name(); } String name() { return "A"; } }
class B extends A { String name() { return "B"; } }
Medium

Discussion (0)

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

Log in to join the discussion.