Question: Q1: Write a complete JAVA program that carries out the following tasks: - Declare a class TV with the following non-static data members: sname (
Q1: Write a complete JAVA program that carries out the following tasks: - Declare a class TV with the following non-static data members: sname ( Type String). s price (Type double). - The class also contains the following static data members: rnumber (Type int ). - The class also contains the following methods: default-constructor to give initial values for all data members. constructor that accepts values of all data members as arguments from the user. Constructor that accepts the price as the only argument. setName 0 method to reset the name of the TV. getName method to return the name of the TV. setPrice O method to reset the price of the TV. getPrice 0 method to return the price of the TV. display 0 method that prints out the class data. I main 0 method to test the functionality of the class, asking the user to enter any necessary data. Note: the static data member (number) is set to 0 and it is increment by 1 when an object is instantiated. Q2: What happens when we write the following code in the main method: system.out.println("Name of tv1 is " + tv1. name): System.out.println("Price of tv2 is " + tv2.price); What is the solution for the above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
