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
Assume that strikeCounter has already been declared to be a "pointer to int". Assume further that strikeCounter has been initial
Feliz [49]

Answer:

int* strikeCounter ;

int someVal;

scanf("%d", &someVal);

strikeCounter =&someVal;

*strikeCounter =someVal*4;

Explanation:

Here we took one int variable and read that value from user. we assigned that int variable address to pointer variable "strikeCounter " and we are pointing the value of strikecounter as 4 times of that integer variable value

8 0
4 years ago
What is a wireless network that provides communication over a short distance that is intended for use with devices that are owne
andrew11 [14]

Answer: personal area network

Explanation:

it can connect personal devices to make network, the personal network are phone,laptop,printer and soon in order to communicate.

3 0
3 years ago
Read 2 more answers
What is the main purpose of adding captions to an image or table in Word?
Wittaler [7]

Answer: c

Explanation:

7 0
3 years ago
An administrator has added a firewall within an Azure virtual network. What do we know for sure about the firewall?
slavikrds [6]

Answer:

its a host based firewall

Explanation:

because the administrator put it ntentionally and the only way do disable the firewall is by signing in as the admin (if you're the admin) and turn it off manualy

or if you're not the admin, ask them to do so.

5 0
3 years ago
Five uses of the start button
Damm [24]

Starting something

Possibly turning it off

Making something work

Fixing the Start Button

Beginning something

5 0
3 years ago
Other questions:
  • What possible effects could cyber attack have on Johannesburg stock exchange
    6·1 answer
  • A broadcast network is one in which a transmission from any one attached station is received by all other attached stations over
    10·1 answer
  • Look at the following list of peripheral items and determine what type they are: mouse, keyboard, webcam, microphone. Input Outp
    15·1 answer
  • As a digital forensics examiner, it’s a good idea to build a list of references for information on privacy laws in other countri
    13·1 answer
  • ​open-source software is​ ________.
    11·1 answer
  • Briefly tell me what a PUT request does
    11·1 answer
  • In a dark place you have only a match , a twig , campfire logs , and oil lamp and a candle which do you literally first /
    15·1 answer
  • Video games, regardless of their level of realish, had added a new dynamic to the world games and Entertainment the ability to s
    9·1 answer
  • What is the advantage of learning through story compared to learning through personal experience?
    7·2 answers
  • Complete the code to create a new file.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!