public interface OnOffAble { void turnOff(); void turnOn(); } } public abstract class Lamp implements OnOffAble { public void turnOn(){ System.out.print("Lamp On: "); } } public abstract void turnOff(); public class Floor Lamp extends Lamp { public void turnOff() { System.out.print("Floor Off: "); } } public void turnon () { public interface Dimmable { void setTo(int value); } } System.out.print("Dimmable On: "); Consider this instantiation code: Room r= new Room(); OnOffAble p= new Floor Lamp(); public class Dimmable Floor Lamp extends Floor Lamp implements Dimmable { public void turnOff() { System.out.print("Dimmable Off: "); r.set Lamp ((Floor Lamp) p); r.turnLightOn(); r.turnLightoff(); Will it compile, and if yes, what will it print? } public void setTo(int value) { System.out.print("Dimmable DimVal:" + value + ": "); O a. Runtime Error O b. Lamp On: Dimmable Off: O c. Lamp On: Floor Off: O d. Dimmable On: Dimmable Off: O e. Dimmable On: Floor Off: public class Room { private Lamp 1; void setLamp (Lamp 1){ this.1 = 1; } } void turnLightoff() { 1. turnOff(); } void turnLighton() { 1. turnOn(); }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

Answer it ASAP I will upvote you pls provide correct and accuracy answer if you provide wrong answer i will report you and only text format not in photos 

public interface OnOffAble {
void turnOff();
void turnOn();
}
}
public abstract class Lamp implements OnOffAble {
public void turnOn () {
System.out.print("Lamp On: ");
}
public class Floor Lamp extends Lamp {
public void turnOff() {
System.out.print("Floor Off: ");
}
}
public abstract void turnOff();
}
}
public void turnOn(){
public interface Dimmable {
void setTo(int value);
}
}
System.out.print("Dimmable On: ");
Consider this instantiation code:
Room r= new Room();
OnOffAble p = new Floor Lamp();
r.setLamp ((Floor Lamp) p);
r.turnLightOn();
r.turnLightoff();
Will it compile, and if yes, what will it print?
public class DimmableFloor Lamp extends Floor Lamp implements Dimmable {
public void turnOff() {
System.out.print("Dimmable
Off: ");
}
public void setTo(int value) {
System.out.print("Dimmable DimVal:" + value + ": ");
O a. Runtime Error
O b. Lamp On: Dimmable Off:
O c.
Lamp On: Floor Off:
O d.
Dimmable On: Dimmable Off:
O e. Dimmable On: Floor Off:
public class Room {
private Lamp 1;
void setLamp (Lamp 1){
this.1 = 1;
}
}
void turnLightOff() {
1. turnOff();
}
void
}
turnLightOn () {
1. turnOn();
Transcribed Image Text:public interface OnOffAble { void turnOff(); void turnOn(); } } public abstract class Lamp implements OnOffAble { public void turnOn () { System.out.print("Lamp On: "); } public class Floor Lamp extends Lamp { public void turnOff() { System.out.print("Floor Off: "); } } public abstract void turnOff(); } } public void turnOn(){ public interface Dimmable { void setTo(int value); } } System.out.print("Dimmable On: "); Consider this instantiation code: Room r= new Room(); OnOffAble p = new Floor Lamp(); r.setLamp ((Floor Lamp) p); r.turnLightOn(); r.turnLightoff(); Will it compile, and if yes, what will it print? public class DimmableFloor Lamp extends Floor Lamp implements Dimmable { public void turnOff() { System.out.print("Dimmable Off: "); } public void setTo(int value) { System.out.print("Dimmable DimVal:" + value + ": "); O a. Runtime Error O b. Lamp On: Dimmable Off: O c. Lamp On: Floor Off: O d. Dimmable On: Dimmable Off: O e. Dimmable On: Floor Off: public class Room { private Lamp 1; void setLamp (Lamp 1){ this.1 = 1; } } void turnLightOff() { 1. turnOff(); } void } turnLightOn () { 1. turnOn();
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,