parent class constructor is called automatically when child class is instantiated in java -


abstract class {     abstract void method(); }  class b extends {     b() {     }      void method() {     } }  class c extends b {     c() {     } } 

when instantiate class c in main, automatically calls constructor b (parent class). normal or doing wrong?

there nothing wrong, there implicit call super constructor.

you haven't written constructor class c default constructor provided compiler be.

c(){   super();   } 

if default constructor provided, there call super(). in case, c extends b constructor of b gets called.

if not class other class, default extends object class. object class constructor called.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -