classOtherClass{publicstaticvoidmain(String[] args){Car myCar =newCar();// Create a myCar object
myCar.fullThrottle();// Call the fullThrottle() method
myCar.speed(200);// Call the speed() method}}
publicclassCar{publicvoidfullThrottle(){System.out.println("The car is going as fast as it can!");}publicvoidspeed(int maxSpeed){System.out.println("Max speed is: "+ maxSpeed);}}
Result:
The car is going as fast as it can!
Max speed is: 200