//Method Overloading classMotor Bike { 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 LabTask17a { public staƟc void main(String args[]) { MotorBike b=new MotorBike(); b.start(); b.start("Self"); } } //Method Overriding classMotor Bike { public void start() { System.out.println("Using kick paddle to start..."); } } classSelfStartMotorBike extends MotorBike { public void start() { System.out.println("Using self start buƩon to start..."); } } public class LabTask17b { public staƟc void main(String args[]) { SelfStartMotorBike b=new SelfStartMotorBike(); b.start(); } }
Preview:
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