Question 1 of 10
A booth shades a lamp through a parameter. What text does this Java code display?
public class Lamp {
private int watts;
public Lamp(int w) {
watts = w;
}
public void dim(int n) {
watts -= n;
}
public int getWatts() {
return watts;
}
}
public class Booth {
public void shade(Lamp bulb) {
bulb.dim(10);
}
}
Lamp desk = new Lamp(60);
Booth b = new Booth();
b.shade(desk);
System.out.print(desk.getWatts());
- A. 60
- B. 50
- C. 10
- D. 0