Java Constructor

A constructor is same name as class name, constructor is use to initialize the parameter.
We can call parent constructor from child constructor through super keyword.
it will execute when class object is created.
we can call parameterise constructor from this keyword in same class.
A constructor is a block of code like a method but it will be execute at the time object of class is created.

here we created two class Child and Parent. from extends keyword we inherit the child class data in parent class. through super keyword we call child class constructor.

					class Child {
	int salary;

	public Child(int salary) {
		this.salary = salary;

public class Parent extends Child {
	String name;

	public Parent(String name) {
		super(500); = name;

To find more Java Interview Questions And Answer, click the link :- Java

Leave a Comment

Your email address will not be published. Required fields are marked *