Constructor Chaining in Java

Constructor chaining is the way through which a constructor make a call to another constructor. Constructor chaining can be done in 2 ways: Output In the above code we called Example2() constructor for object creation which in turn calls Example2(int age) constructor using this(29). Now inside Example2(int age) constructor a call is made to Example2(int … Read more

Default Constructor in Java

Default constructor is automatically created by the compiler if we do not declare any constructor. The features of default constructor are : Let us look at an example to understand default constructor: Output As you can see in the above code we have not created any constructor in our class TestA, still instance variables age … Read more