Question: JAVA 1 . Create a Computer class with the following attributes: int type core , double type speed , long type memory . Create the

JAVA1. Create a Computer class with the following attributes: int type core, double type speed, long type memory. Create the following constructors and methods:
a. Default constructor which will initialize the attributes to the following values:
core to 1,speed to 2.1e9, and memory to 4000000000L.
b. Parameterized constructor which will initialize the attributes. [clue... there will be three parameters and those will correspond to the attributes]
c. Get methods for all the attributes [remember that each get method will have return type similar to the corresponding attribute and it wont have any parameter]
d. Set methods for all the attributes [remember that each set method will take a parameter that matches the corresponding attribute and it will modify the value of the corresponding attribute.]
2. Create Driver class and add main method
i. Within the main method instantiate an object of type Computer with default constructor. Computer comp = new Computer();
ii. Now, print the number of cores, speed and memory size of your computer.
iii. Now instantiate another object of Computer type with parameterized constructor. Provide the values of your choice for the parameters.
Computer comp = new Computer( core, speed, memory );
iv. Now, print the number of cores, speed and memory size of your computer

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!