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]
4 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]4 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
The position of a _____ is a nontechnical position responsible for defining and implementing consistent principles for setting d
Cloud [144]

Answer:

jf

Explanation:

nvfmnv

7 0
3 years ago
The Save command saves your changes silently without additional prompts, using the same save settings; the Save As command reope
kirza4 [7]

The "Save command" saves your changes <u>silently</u> without additional prompts and it uses the same save settings while the "Save As command" <u>reopens</u> the Save screen: True.

What is the Save command?

A Save command can be defined as a type of command associated with the file menu of a software application and it causes a copy of the current file to be created and stored to a specific location on a computer system.

<h3>What is the Save as command?</h3>

A Save command can be defined as a type of command associated with the file menu of a software application and it causes a copy of the current file to be created and stored to a different location, file name, and/or file type.

In conclusion, the "Save command" saves your changes <u>silently</u> without additional prompts and it uses the same save settings while the "Save As command" <u>reopens</u> the Save screen, so as to enable you make different choices.

Read more on Save command here: brainly.com/question/16852455

5 0
3 years ago
What is the output of this program? Assume the user enters 3, 6, and 11.
erica [24]

Answer:

14.0

Explanation:

3 0
1 year ago
Cool fchgjvkugyftdycfhgjkliugytbnhmjku
alexandr1967 [171]

Answer:

the cats face XD

Explanation:

3 0
3 years ago
Given the following function definition, what modifications need to be made to the search function so that it finds all occurren
Naddika [18.5K]

Answer:

The answer is "Option b".

Explanation:

In the given question, a function "search" is defined. That searches element that is passed in the function by parameter. To search more quickly we must add another parameter in the function. and other options are not correct that can be described as:

  • In option a, We add another element in parameter to start searching not to stop.
  • In option c, The function can not find an element that occurs in the array target.
  • In option d, Function will not return array it will return only index value.

7 0
3 years ago
Other questions:
  • "explain why professional software is not just the programs that are developed for a customer"
    7·1 answer
  • Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space.
    7·1 answer
  • What does it mean when your phone says system ui has stopped?
    7·1 answer
  • Explain the difference between good and bad table structures. How do you recognize the difference between good and bad structure
    14·1 answer
  • Create a horizontal line across middle of the entire form. To code this the ____ values are the same.
    7·2 answers
  • Help pls. Computer basics.
    5·2 answers
  • Three common risk factors for young drivers and how you plan to minimize these factors.
    13·1 answer
  • Kali, a Python programmer, is using the turtle module to write the word "hello." Which code should she use to indicate the locat
    9·2 answers
  • Why computer is known as versatile and diligent device? Explain​
    7·1 answer
  • Is the ability to choose the start and finish times, but they must complete a full day’s work
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!