1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
marshall27 [118]
3 years ago
11

Design 3 classes: Computer - Superclass

Computers and Technology
1 answer:
wlad13 [49]3 years ago
5 0

Answer:

Explanation:

The following code is written in Java. It creates the three classes mentioned and a Tester class that contains the main method. The Computer class contains the memory variable since both laptops and Desktops need memory. The screen size variable is placed separately in the Laptop and Desktop class since desktops may or may not have a monitor so this variable cannot be placed in the Computer class. The batteryLife variable is only in the Laptop class because Desktops do not have batteries. Finally, the monitor variable is only placed in the Desktop class since Laptop's come with built-in monitors. The tester class seen in the picture below tests the creation of both of these objects and it executes without any error.

class Computer {

   int memory;

   public int getMemory() {

       return memory;

   }

   public void setMemory(int memory) {

       this.memory = memory;

   }

}

class Laptop extends Computer {

   int screenSize;

   double batteryLife;

   public int getScreenSize() {

       return screenSize;

   }

   public void setScreenSize(int screenSize) {

       this.screenSize = screenSize;

   }

   public double getBatteryLife() {

       return batteryLife;

   }

   public void setBatteryLife(double batteryLife) {

       this.batteryLife = batteryLife;

   }

}

class Desktop extends Computer {

   boolean monitor;

   int screenSize;

   public boolean isMonitor() {

       return monitor;

   }

   public void setMonitor(boolean monitor) {

       this.monitor = monitor;

   }

   public int getScreenSize() {

       return screenSize;

   }

   public void setScreenSize(int screenSize) {

       this.screenSize = screenSize;

   }

}

class Tester {

   public static void main(String[] args) {

       Laptop computer1 = new Laptop();

       Desktop computer2 = new Desktop();

   }

}

You might be interested in
SP 800-14, Generally Accepted Principles and Practices for Securing Information Technology Systems, provides best practices and
Alika [10]

Answer:

blueprint.

Explanation:

Generally Accepted Principles and Practices for Securing Information Technology Systems, provides best practices and security principles that can direct the security team in the development of a security blueprint.

3 0
3 years ago
Read 2 more answers
Which of the following is an advantage of batch processing?
alina1380 [7]

Answer:

it can balance computing resources by time

Explanation:

this this is as it involves multiprogramming

8 0
3 years ago
Give 5 comparisons of the three employees with the highest net pay
Anna71 [15]

Answer:

this is wot u get for not paying attiention on class

Explanation:

3 0
2 years ago
Read 2 more answers
Ivy is a student. She is looking for some freelance assignments during her vacation. Which of the following networking sites can
lara [203]

The answer is D. XING


3 0
3 years ago
Complete the concept map on computer as outlined below​
USPshnik [31]

Answer:

Here is your answer.

have a great day

6 0
3 years ago
Other questions:
  • When programming, the word "execute" means which of these?
    13·1 answer
  • ISBN-13 is a new standard for identifying books. It uses 13 digits d1d2d3d4d5d6d7d8d9d10d11d12d13. The last digit d13 is a check
    9·1 answer
  • Yellow and blue light are projected on a white screen. what color will the screen appear to be?
    6·2 answers
  • What component of a computer system holds the operating system when the computer is not running
    6·2 answers
  • Liz's meeting is scheduled to end at 9:30. It is 9:20 and team
    9·1 answer
  • In the MOV instruction both operands i.e. source andthe destination cannot be
    15·2 answers
  • Quantas calorias os adolescentes devem consumir diariamente?
    14·1 answer
  • Among the following, which is the best protection against ransomware?
    8·1 answer
  • What allows users to connect via the Internet to its private network?
    11·2 answers
  • Peripeteia is also referred to as __________.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!