Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 8 1 pts Skip to question text. Select the statement that reveals the lo

ID: 640149 • Letter: Q

Question

Question 8 1 pts Skip to question text.

Select the statement that reveals the logic error in the following method.

public static double minimum(double[] data)
{
double smallest = 0.0;
for (int i = 0; i < data.length; i++)
{
if (data[i] < smallest)
{
smallest = data[i];
}
}
return smallest;
}

Flag this Question

Question 9 1 pts <p>What is the output of the code snippet below?</p> <p>int[][] arr = <br>{<br> { 1, 2, 3, 0 },<br> { 4, 5, 6, 0 },<br> { 0, 0, 0, 0 }<br>};<br>int val = arr[1][2] + arr[1][3];<br>System.out.println(val);</p>

What is the output of the code snippet below?

int[][] arr =
{
{ 1, 2, 3, 0 },
{ 4, 5, 6, 0 },
{ 0, 0, 0, 0 }
};
int val = arr[1][2] + arr[1][3];
System.out.println(val);

Flag this Question

Question 10 1 pts <p>Which statement is true about the code snippet below?</p> <p>ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();<br>names.add("John");<br>names.add("Jerry");<br>ArrayList&lt;String&gt; friends = names;<br>friends.add("Harry");</p>

Which statement is true about the code snippet below?

ArrayList<String> names = new ArrayList<String>();
names.add("John");
names.add("Jerry");
ArrayList<String> friends = names;
friends.add("Harry");

Flag this Question

Question 11 1 pts <p>Which of the following most likely indicates that you have chosen a good name for your class?</p>

Which of the following most likely indicates that you have chosen a good name for your class?

Flag this Question

Question 12 1 pts Skip to question text.

Given the following class definition, which of the following are considered part of the class

double m = minimum(new double[] { 1.2, -3.5, 6.6, 2.4 });

Explanation / Answer

Note: Question 12 is incomplete and thus not included in the solution.

Question 8

The correct answer is option D.

Option D is:

double m = minimum(new double[] { 12.2, 31.5, 6.6, 2.4 });

Here all values are greater than zero, then the smallest returned will be 0.0 which is already initialized in the code.

Rest all options has some values less than zero.

Question 9

The correct answer is option B

Consider the array initialization as shown:

int[][] arr =
{
{ 1, 2, 3, 0 },
{ 4, 5, 6, 0 },
{ 0, 0, 0, 0 }
};

arr[1][2] means first row and second column where rows and columns both start from the index 0. Therefore, arr[1][2] = 6.

Similarly, arr[1][3] means first row and third column where rows and columns both start from the index 0. Therefore, arr[1][3] = 0.

Thus, arr[1][2] + arr[1][3] = 6+0

                                       = 6

Question 10

The correct answer is option C

names is the object of the ArrayList. Two names are added. Then another object friends is created, and is assigned the address of the object names. Thus both the objects will have size 3.

Question 11.

The correct answer is option D

The good class name depicts its functionality. Preferably it should be a verb.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote