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
Sav [38]
3 years ago
7

Questions 6 - 9 Refer to the following code: public class WhatsIt { private int[] values; private double average; public WhatsIt

() { values = new int[10]; findAvg(); } public WhatsIt (int[] n) { values = n; findAvg(); } public void findAvg () { double sum = 0; for (int i = 0; i < values.length; i++) { sum += values[i]; } average = 1.0 * sum / values.length; } public String toString() { return "Average: " + average + " Length: " + values.length; } } What does the line findAvg(); in the constructor do? Creates a reference to the average variable. Calls the method findAvg() so the variable average is updated correctly. Calls the constructor findAvg; so the object can be created in memory. This call should be removed. Checks to see if the average variable has been initialized
Computers and Technology
1 answer:
gavmur [86]3 years ago
4 0

Answer:

class WhatsIt

{

private static int [] values;

private double average;

public Double Average=average;

public WhatsIt () {values = new int [10]; findAvg(); }

public WhatsIt (int [] n) {values = n; findAvg(); }

public static void findAvg ()

{double sum = 0;

for (int i = 0; i < values.length; i++)

{sum += values[i]; }

average = 1.0 * sum / values.length;

System.out.println(Average);

System.out.println(average);

}

public static String ToString()

{

   System.out.println(average); System.out.println(values.length);

   return "Average: " + average + " Length: " + values.length;

}

public static void main(String[] args)  

{

    //WhatsIt();

    //ToString();

    findAvg();

}

}

The findAvg() calculates the average.

The reference to average is defined as below:

public double Average=average;

And when we call findAvg average is initialized, and Average is also initialized, which we can check through println statement.

Explanation:

Please check the answer section.

You might be interested in
Brian has been working for a few years now and has saved a substantial amount of money. He now wants to invest 50 percent of his
babunello [35]
It should be Money market or CD. I'm leaning towards Money Market account.
8 0
3 years ago
Read 2 more answers
The specific instructions that a computing device needs to boot up and control the hardware
dlinn [17]

Answer:

Firmware

Explanation:

7 0
2 years ago
what field in the ipv4 datagram header can be used to ensure that a packet is forwarded through no more than N headers
andrew-mc [135]

Answer:

Time to Live (or TTL)

Explanation:

This counter field is initially set at some value that is decremented by one each time the packet "hops." When the counter reaches zero the packet is disposed of.

5 0
2 years ago
Which wireless communication technology is most likely used when synchronizing device information to an automobile?
seropon [69]
Bluetooth is the most reasonable answer
8 0
3 years ago
Hey plz help me with this<br>What is malware short for?​
soldier1979 [14.2K]

Answer:

Malware is the collective name for a number of malicious software variants, including viruses, ransomware and spyware. Shorthand for malicious software, malware typically consists of code developed by cyberattackers.

Explanation:

4 0
2 years ago
Other questions:
  • Airbags only absorb the _____ impact in a crash. initial final mid-stage smallest
    13·1 answer
  • Edhesive coding practice 3.4​
    12·1 answer
  • The region which satisfies all of the constraints in graphical linear programming is called the:
    8·1 answer
  • A cybersecurity analyst is currently investigating a server outage. The analyst has discovered the following value was entered f
    9·1 answer
  • Which two statements are true about the Data Sync functionality? (Choose two.)
    15·1 answer
  • Explain how SEO impacts the way you should interpret search engine results ???
    6·1 answer
  • 3. Describe at least 3 nonprice competition strategies a company could use to convince customers that its product is better than
    5·2 answers
  • What is the gear ratio?
    12·1 answer
  • Explain how mobile phone production could be more sustainable​
    8·2 answers
  • What critical-thinking tool is being used when asking the question, "Is there a large enough scope of
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!