0
Why last output is printed?
Why Here man class is empty but it is calling parents class member? Anyone please tell me the reason ? https://code.sololearn.com/c7wxer3dYRFq/?ref=app
3 Answers
+ 5
On!oN
In Java there is default constructor. So no need to define it. There is other types of constructor also like parameterized and copy constructor. For parameterized constructor, you have to explicitly define it.
Also constructor is used to initialise objects, set default data. Constructor is not used to call method. To call method you have to create object of class.
0
Yeah , but there's no any construction then how any method called?
0
ćļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć i mean, in parent class there's no constructor then how can method is called?
And by inheritance it inherited the behaviour of parent class but just making an object , how method is called?