subject

Consider the following class definitions. public class Computer { private String memory; public Computer) { memory = "RAM"; } public 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.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:10
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Which software would you use to create a print design? a. illustrator b. audacity c. reaper d. dreamweaver
Answers: 2
question
Computers and Technology, 23.06.2019 03:30
Hashtags serve to identify the topic of a given tweet true false
Answers: 2
question
Computers and Technology, 24.06.2019 02:30
Write the pseudo code for this problem based on what you learned from the video. the purpose is to design a modular program that asks the user to enter a distance in kilometers, and then converts that distance to miles. the conversion formula is as follows: miles = kilometers x 0.6214
Answers: 3
You know the right answer?
Consider the following class definitions. public class Computer { private String memory; public Comp...
Questions
question
Mathematics, 26.01.2021 21:50
question
Physics, 26.01.2021 21:50
question
Mathematics, 26.01.2021 21:50
question
Chemistry, 26.01.2021 21:50
Questions on the website: 13722363