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
. List 5 types of exploits from cybercrime and provide brief definition. (2.5 Marks)
Flura [38]

In cyber security, an exploit is a way attackers take advantage of certain vulnerabilities and gain malicious access to systems. There are very many types of exploits that exist in the cyber security world. However, I will mention those ones most commonly used.

DoS attacks – The denial of service attacks is very common. Hackers will gain access to servers and send so many packet requests at the same time. The servers become overwhelmed due to too much memory allocation and the huge amount of traffic ends up crashing the servers.

Unauthorized access – When an attacker has an illegal access to host machines

<u>Application Exploitation</u>

Code injection – This exploit can be used to maliciously inject invalid code into an application program or software and as a result change how the program behaves.

Cross-site scripting – Enable hackers inject malicious scripts on a website of a client. Once they have gained access, they will escalate their privileges and have more access to the site.

Clickjacking – A type of attack that tricks unknown victims into clicking links of a web page they believe are legitimate and end up revealing confidential information of themselves.

6 0
3 years ago
The Internet Engineering Task Force (IETF) defines the protocols and standards for how the Internet works. The members of the IE
belka [17]

<em>Answer:</em>

<em>A loosely organized collection of citizens and engineers who communicate mostly by email. </em>

Explanation:

6 0
3 years ago
Create a static method called fillArray, which takes an integer array as an input parameter, along with an integer initial value
JulijaS [17]

Answer:

public class print{

   

   public static void fillArray(int[] arr, int initialValue){

       

       int n = arr.length;

      for(int i=0;i<n;i++){

          arr[i] = initialValue++;

      }

       for(int i=0;i<n;i++){

           System.out.print(arr[i]+" ");

      }

       

   }

    public static void main(String []args){

       

        int[] array = new int[5];

        int initialValue =3;

       

        fillArray(array,initialValue);

       

    }

}

Explanation:

Create the function with two parameter first is array and second is integer.

Then, declare the variable and store the size of array.

Take the for and fill the array from the incremented value of initialValue  by 1 at every run of loop.

After loop, print the element of the array.

Create the main function which is used for calling the function and also declare the array with size 5 and initialValue with 3. After that, call the function with this argument.

3 0
3 years ago
What are the controls in the Capture panel? Define each controls
MArishka [77]

Answer:

.............

........

8 0
2 years ago
A _____ is a type of legal protection for which person can apply to protect an invention or a discovery.
shepuryov [24]

Answer:

patent

Explanation:

A patent is an intellectual property, with this legal protection, we can exclude to use, sell, and importation of an invention for a limited period of years, but we must do an enabling public disclosure of the invention or discovery, it is a requirement of the patent law, a patent is considered an advantage in the industries world.

3 0
3 years ago
Other questions:
  • On what dates did the 2016 Olympics take place( list all)
    9·2 answers
  • What does "FDDI" stand for in Technology?
    5·2 answers
  • Why is it a mistake to put email addresses of people who don't know each other in the "To:" field?
    8·2 answers
  • What is a mortgage?
    8·2 answers
  • Write a program that prompts the user to enter the year and the first three letters of a month name (with the first letter in up
    8·1 answer
  • "PindCart, an online retailer, places a small file on the computer hard drive of its visitors to recognize them when they revisi
    7·1 answer
  • ERP packages are always quite simple.<br><br> True<br><br> False
    5·1 answer
  • 1. Accessing calendars, contact information, emails, files and folders, instant messages, presentation, and task lists over the
    7·1 answer
  • _____________ helps to control and limit the number of consecutive request failures that cross a threshold. Review breaker Micro
    7·1 answer
  • Ok.,so i have a sopitify account and by accident i pressed the downlaod on button and it says start you free trial i pressed tha
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!