Preview:
//Method Overloading 

classMotorBike 

{ 

private String startMethod = "Kick"; 

public void start() 

 { 

System.out.println(startMethod+" starƟng...");

 } 

public void start(String method) 

 { 

this.startMethod = method; 

System.out.println(startMethod+" starƟng...");

 } 

} 

public class LabTask18a 

{ 

public staƟc void main(String args[])

 { 

MotorBike b=new MotorBike(); 

b.start(); 

b.start("Self"); 

 } 

}

//Constructor Overloading 

class LabTask18b 

{ 

 String lang; 

LabTask18b() 

 { 

this.lang="Java"; 

 } 

LabTask18b(String lang) 

 { 

this.lang=lang; 

 } 

public void getLang() 

 { 

System.out.println("Programming Langauage: "+this.lang); 

 } 

public staƟc void main(String[] args) 

 { 

 LabTask18b obj1=new LabTask18b(); 

 LabTask18b obj2=new LabTask18b("C++"); 

obj1.getLang(); 

obj2.getLang(); 

 } 

}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter