whats a default constructor code example
Example 1: default constructor
public class Vehicle {
protected String vin;
protected int modelYear;
public Vehicle() { }
public Vehicle(String vin) {
this.vin = vin;
}
public Vehicle(String vin, int modelYear) {
this.vin = vin;
this.modelYear = modelYear;
}
}
Example 2: default constructor java
class NoteBook{
NoteBook(){
System.out.println("Default constructor");
}
public void mymethod()
{
System.out.println("Void method of the class");
}
public static void main(String args[]){
NoteBook obj = new NoteBook();
obj.mymethod();
}
}