question archive How to call the default constructor in parent class? I called the parent class like following: class name extends list{, but how can I call the default constructor when I have done like this?

How to call the default constructor in parent class? I called the parent class like following: class name extends list{, but how can I call the default constructor when I have done like this?

Subject:Computer SciencePrice:9.82 Bought3

How to call the default constructor in parent class? I called the parent class like following: class name extends list{, but how can I call the default constructor when I have done like this?

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

We can call a default constructor by calling it when a object is created.

class Bike1{  

Bike1()
{
System.out.println("Bike is created");
}  
 
public static void main(String args[]){  
  
Bike1 b=new Bike1();  
}  
}  

Step-by-step explanation

So in the above code we see that a bike method which is a constructor since it is the same name is declared. This is the default constructor here. So in the main function we create a object called b. When we create this we call the method of Bike. The output of the code will be "Bike is created".