Question: Appliance.java public class Appliance { //Declaring instance variables private String name; private String location; int value; //Zero argumented constructor public Appliance() {} //Parameterized constructor public

Appliance.java

public class Appliance { //Declaring instance variables private String name; private String location; int value;

//Zero argumented constructor public Appliance() {}

//Parameterized constructor public Appliance(String name, String location, int value) { this.name = name; this.location = location; this.value = value; }

//getters and setters public String getName() { return name; }

public void setName(String name) { this.name = name; }

public String getLocation() { return location; }

public void setLocation(String location) { this.location = location; }

public int getValue() { return value; }

public void setValue(int value) { this.value = value; }

//toString method is used to display the contents of an object inside it @Override public String toString() { return "The " + name + " is located in the " + location; }

}

__________________

TV.java

public class TV extends Appliance { //Declaring instance variables private int size; private int channel; private int volume; //Zero argumented constructor public TV() {

} //Parameterized constructor public TV(String name, String location, int value, int size, int channel, int volume) { super(name, location, value); this.size = size; this.channel = channel; this.volume = volume; } //getters and setters public int getSize() { return size; } public void setSize(int size) { this.size = size; } public int getChannel() { return channel; } public void setChannel(int channel) { this.channel = channel; } public int getVolume() { return volume; } public void setVolume(int volume) { this.volume = volume; } //toString method is used to display the contents of an object inside it @Override public String toString() { return "The " + getName() + " is located in the " + getLocation() + " and is on channel " + channel; }

}

_________________

Client.java

public class Client {

public static void main(String[] args) {

//Creating an Instance of TV class object by passing the values as arguments

TV tv1=new TV("Hitachi","Bedroom",399,32,1215,0);

//Displaying the TV class info

System.out.println(tv1);

}

}

_________________

Output:

The Hitachi is located in the Bedroom and is on channel 1215

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!