(1) abstract class, class or interface
(2) Tool, Drill, or PowerDrill
(3) apply(int minutes), apply(), apply(int minutes) {}, or
apply() {}
(4) class, interface, abstract class
(5) void turnOff() or void turnOn()
(6) void turnOff() or void turnOn()
(7) interface, class, abstract class
(8) implements or extends
(9) extends or implements
(10) protected void apply (int minutes) , private void apply
(int minutes), or public void apply (int minutes)
Instructions: Declare an interface named Tool with a single method apply. The method has a single parameter of type int named minutes but does not return any value. Implement an abstract class named Drill). The class has a boolean variable and implements two methods turnon) and turnoff). Both have no parameters and do not return any values. Implement a class named PowerDrill. The class inherits from (Drill and implements the Tool interface. The apply method outputs a message "drilling for {X} minutes" where {X} is the minutes argument that is passed to the method, e.g. "drilling for 5 minutes"! Solution public [Select] [Select] void [Select] } public [Select] boolean isOn: public [Select] this.isOn = true; } public [Select] } this.isOn false; YE PowerDrill [Select] Tool { [Select] System.out.println("drilling for " + minutes + "minutes"); Drill { } public [Select] [Select] Drill
(1) abstract class, class or interface (2) Tool, Drill, or PowerDrill (3) apply(int minutes), apply(), apply(int minute
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am