Pergunta de entrevista da empresa Wipro

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

Respostas da entrevista

Sigiloso

18 de mai. de 2017

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

Sigiloso

5 de ago. de 2018

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

Sigiloso

5 de ago. de 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.