Wipro Interview Question

Inheritance related. given two classes, A has public static void main() method. B extends A which is an empty class. what happens when we run B class

Interview Answers

Anonymous

May 18, 2017

Tricky one. But, without a main method in Subclass. How is it possible?

Anonymous

Aug 5, 2018

Since B class extends A, the A.main() method will be called.

Anonymous

Aug 5, 2018

Elaborating the above answer, since class B extends class A but class B doesn't have the main() method, the A.main() method will be called.