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.");
}
}