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
What command would you use to view the path taken by an ethernet packet in windows?
Anni [7]
Hey there,
The answer is <span>tracert.

Hope this helps :))

~Top
</span>
5 0
3 years ago
When a function changes the value of reference parameter, the value of the actual parameter will get changed as well.
blondinia [14]

Answer:

True

Explanation:

The variable in the function and the actual variable are one and the same.

6 0
4 years ago
CodeHS 2.1.4 Evidence collection.
dedylja [7]

Answer:

The term computer is derived from the Latin term 'computare', this means to calculate or programmable machine. Computer can not do anything without a Program. It represents the decimal numbers through a string of binary digits. The Word 'Computer' usually refers to the Center Processor Unit plus Internal memory.

Explanation:

6 0
2 years ago
When you use the ip address of the web server, the correct site is displayed?
jekas [21]
No. Using the address will get you either the default site, or the first site declared. Web servers can host VirtualHosts, and rely on the site name to know which VirtualHost to serve. TMI, it's called name based virtual host, as opposed to the machine having many addresses then address based virtual hosts can be created.
6 0
4 years ago
Explain the strengths and weaknesses you have experienced with content information
denis23 [38]
On which story its not here?
4 0
3 years ago
Other questions:
  • Suppose a subnet has a prefix 128.119.44.128/26. Give an example of an IP address from this subnet. If an ISP owns a block of ad
    14·2 answers
  • Write a program that takes as input an arithmetic expression followed by a semicolon ";". The program outputs whether the expres
    11·1 answer
  • What feature would be used to collect how many times users downloaded a product catalog?
    11·1 answer
  • What are the examples of personal computers ?
    8·1 answer
  • Write a Java program to accept an item's name and price from the user and output them to the console
    5·1 answer
  • Select the statements that are true regarding the future of technology. Select 2 options.
    12·1 answer
  • I still haven't figured out how to award someone branliest will someone help me? If you explain to me how to do it i will do awa
    14·1 answer
  • The program is the set of instructions a computer obeys
    7·1 answer
  • Thinking about the operations needed in these games, which game is likely to be one of the oldest games in the world?
    14·2 answers
  • In the context of in-house software development options, a firm that enhances a commercial package by adding custom features and
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!