55.8k views
2 votes
Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off. The following methods provide these behaviors: turnOn and turnOff. Both methods accept no arguments and return no value. Assume there is a reference variable officeAC of type AirConditioner. Create a new object of type AirConditioner and save the reference in officeAC. After that, turn the air conditioner on using the reference to the new object.

1 Answer

2 votes

//making reference object.

// the following line will declare a officeAC object of type AirAconditioner by //calling the class constructor by reference using "new" operator.

AirConditioner officeAC = new AirConditioner();

// the following line will can the method of class AirConditioner to turonOn //the AC

officeAC.turnOn();

User Packoman
by
5.0k points