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
Anastaziya [24]
2 years ago
5

Consider the following class definitions. public class Computer { private String memory; public Computer) { memory = "RAM"; } pu

blic Computer (String m) { memory = m; } public String getMemory () { return memory; ) } public class Smartphone extends Computer private double screenWidth, screenHeight; public Smart Phone (double w, double h) super("flash"); screenWidth = w; screenHeight = h; } public double get ScreenWidth() { return screenWidth; } public double getScreenHeight() { } return screenHeight; } The following code segment appears in a class other than Computer or Smartphone. + Computer myPhone = new Smart Phone (2.55, 4.53); System.out.println("Device has memory: " + myPhone.getMemory () ", screen area: " + myPhone.getScreenWidth()* myPhone.getScreenHeight() + " square inches."); The code segment is intended to produce the following output. Device has memory: flash, screen area: 11.5515 square inches. Which of the following best explains why the code segment does not work as intended?A. An error occurs during compilation because a Smartphone object cannot be assigned to the Computer reference variable myPhone. B. An error occurs during compilation because the Smartphone class has no getMemory method. C. An error occurs during compilation because the getScreenWidth and getScreenHeight methods are not defined for the Computer object myPhone. D. An error occurs at runtime because the Smartphone class has no getMemory method. E. An error occurs at runtime because the getScreenWidth and getScreenHeight methods are not defined for the Computer object myPhone.
Computers and Technology
1 answer:
chubhunter [2.5K]2 years ago
8 0

Answer:

C.

Explanation:

The code provided in the question has many syntax errors. I have pasted a fixed version of the code below that fixes all the syntax errors but leaves the code as is. Using this code you can see that the error that is preventing the code from running properly is that

C. An error occurs during compilation because the getScreenWidth and getScreenHeight methods are not defined for the Computer object myPhone.

As you can see from the attached photo below, the code is failing to compile because the methods themselves are not able to be accessed by the myPhone object. This is happening during the compilation and thus causing the compilation to fail.

class Computer {

   private String memory;

   public Computer() {

       memory = "RAM";

   }

   public Computer(String m) {

       memory = m;

   }

   public String getMemory() {

       return memory;

   }

}

   class Smartphone extends Computer {

       private double screenWidth, screenHeight;

       public Smartphone(double w, double h) {

           super("flash");

           screenWidth = w;

           screenHeight = h;

       }

       public double getScreenWidth() {

           return screenWidth;

       }

       public double getScreenHeight() {

           return screenHeight;

       }

   }

   public class Main{

       //The following code segment appears in a class other than Computer or Smartphone

       

       public static void main(String[] args) {

           Computer myPhone = new Smartphone(2.55, 4.53);

           System.out.println("Device has memory: " + myPhone.getMemory() + ", screen area: " + (myPhone.getScreenWidth()*myPhone.getScreenHeight()) +" square inches.");

       }

   }

You might be interested in
A(n ____ is information that a web server stores on a client computer, such as the client’s preferences when accessing a particu
gayaneshka [121]
<span>A COOKIE is information that a web server stores on a client computer, such as the client’s preferences when accessing a particular web site, or where the client has been on the web site.</span>
7 0
2 years ago
Summarize who you believe cyber criminals are, and why?
sergij07 [2.7K]

Answer:

 The cyber criminals are the people that are engaged with getting the data in an unapproved way and furthermore mischief to the association henceforth are considered as cyber criminals.

Cyber criminals are people or groups of individuals who use innovation to committed the malicious exercises on computerized frameworks or systems with the aim of taking the organization data or individual information and producing benefit.

There are many types of cyber criminals that are:

  • Internet stalkers
  • Cyber terrorist
  • Identity thieves

5 0
3 years ago
PLEASE HELP THIS WAS DUE YESTERDAY AND I DIDN'T GET TO IT IN TIME!!!!!!
kykrilka [37]

Answer:

dDAgv

Explanation:

sdc sdc sdc trust me

7 0
2 years ago
How does the technology work
Ivan

Answer:  it does – or perhaps appears to do – in the world.

Explanation:

sorry if am not right have a nice day lol

6 0
2 years ago
Read 2 more answers
Plzz help will mark brainliest
vlabodo [156]

Answer:

11. 3 dimensions

12. ( i believe its number 3)

13. 2 option

14. Natural Light

15. Development

Explanation:

7 0
3 years ago
Other questions:
  • What are the challenges of photographing at night? Why did the photographer “paint” the waterfall with the flashlight?
    9·1 answer
  • Marissa bought 2 and 1/2 gallons of orange juice to make punch how many quarts of orange juice did Marissa Buy
    15·2 answers
  • A new product was introduced in 2003, which functions as both an identification device and a medium of communication. It uses in
    8·1 answer
  • Today's Apple Mac computers run with the same internal hardware as the Windows-based PC.
    10·2 answers
  • Why is it so important to adhere to principles that have been put forth by reputable organizations to ensure that you are mainta
    10·1 answer
  • Please help thank u!!!!!
    13·2 answers
  • The difference between page break and section brek​
    5·2 answers
  • Which of the following items in the folder window allows users to view locations which have been visited before?
    6·1 answer
  • How to disable Fortinet?
    12·1 answer
  • What is a possible weakness of an expert-novice pair?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!