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

Question 1 Not yet answered Marked out of 1.00 Flag question Question text Which

ID: 3557908 • Letter: Q

Question

Question 1

Not yet answered

Marked out of 1.00

Flag question

Question text

Which of the following about Java arrays is true?
(i) Array components must be of the same type.
(ii) The array index must evaluate to a nonnegative integer less than the length.

Select one:

a. Both (i) and (ii)

b. Only (ii)

c. None of these

d. Only (i)

Question 2

Not yet answered

Marked out of 1.00

Flag question

Question text

int[] alpha = new int[5];

alpha[0] = 22;
alpha[1] = 33;

System.out.println(alpha[0] + " " + alpha[1] + " " + alpha[5]);


What is the output of the code fragment above?

Select one:

a. 0 22 33

b. 22 33 88

c. 22 33 0

d. This program throws an exception.

Question 3

Not yet answered

Marked out of 1.00

Flag question

Question text

Which of the following declares an array of int named beta?

Select one:

a. int beta;

b. int beta = int[];

c. int[] beta;

d. new int beta[];

Question 4

Not yet answered

Marked out of 1.00

Flag question

Question text

Given the following method heading


public static void mystery(int list[], int size)

and the declaration

int[] alpha = new int[75];

Which of the following is a valid call to the method mystery?

Select one:

a. None of these

b. mystery(alpha[75], 50);

c. mystery(alpha, 40);     

d. mystery(alpha[], 50);

Question 5

Not yet answered

Marked out of 1.00

Flag question

Question text

Given the method heading

public static void strange(int a, int b)

and the declaration

int[] alpha = new int[20];
int[] beta = new int[25];

Which of the following is a valid call to the method strange?

Select one:

a. strange(alpha[10], alpha[15]);

b. strange(alpha[5], beta);

c. strange(alpha, beta[20]);

d. strange(alpha[0], beta[25]);

Question 6

Not yet answered

Marked out of 1.00

Flag question

Question text

Which of the following statements creates alpha, an array of 5 components of the type int, and initializes each component to 10?

(i)  int[] alpha = {10, 10, 10, 10, 10};
(ii) int[5] alpha = {10, 10, 10, 10, 10}

Select one:

a. Only (ii)

b. Only (i)

c. Both (i) and (ii)

d. None of these

Question 7

Not yet answered

Marked out of 1.00

Flag question

Question text

given this array declaration:

int [] list = { 2, 4, 3, 99, 23, 5, 11, 21, 75, 3, 51, 15, 12 };

How can you sort the array in numerical order from lowest to highest?

Select one:

a. sort(list);

b. list.sort();

c. sortArray(list);

d. Arrays.sort(list);

Question 8

Not yet answered

Marked out of 1.00

Flag question

Question text

char[][] table = new char[10][5];


How many columns are in the array above?

Select one:

a. 5

b. 15

c. 0

d. 10

Question 9

Not yet answered

Marked out of 1.00

Flag question

Question text

char[][] table = new char[10][5];


How many dimensions are in the array above?

Select one:

a. 5

b. 1

c. 10

d. 2

Question 10

Not yet answered

Marked out of 1.00

Flag question

Question text

Given the declaration

int[] gamma = new int[100];
      
Which of the following for loops set the index of gamma out of bounds?

(i)
      for (int j = 0; j <= 99; j++)
          System.out.print(gamma[j] + " ");
(ii)
      for (int j = 1; j <= 100; j++)
          System.out.print(gamma[j] + " ");
(iii)
      for (int j = 0; j < 100; j++)
          System.out.print(gamma[j] + " ");

Select one:

a. All (i), (ii), and (iii)

b. Only (i)

c. Only (ii)

d. Only (iii)

Question 11

Not yet answered

Marked out of 1.00

Flag question

Question text

Consider the following declaration.
     

double[] sales = new double[100];

Which of the following will correctly initializes all the components of the array  sales to 25.0.

(i)
      for (int j = 0; j < 99; j++)
          sales[j] = 25.0;

(ii)
      for (j = 1; j < 100; j++)
          sales[j] = 25.0;

Select one:

a. Only (i)

b. Both (i) and (ii)

c. None of these

d. Only (ii)

Question 12

Not yet answered

Marked out of 1.00

Flag question

Question text

Consider the following declaration.

     
int[] beta = new int[3];
int j;

Which of the following input statements correctly input values from the scanner in order into the elements of beta? (Assume that console is a Scanner object initialized to the standard input device.)

(i)
      beta[0] = console.nextInt();
      beta[1] = console.nextInt();
      beta[2] = console.nextInt();

(ii)
      for (j = 0; j < 3; j++) {
          beta[j] = console.nextInt();
      }

Select one:

a. Only (ii)

b. None of these

c. Both (i) and (ii)

d. Only (i)

Question 13

Not yet answered

Marked out of 1.00

Flag question

Question text

which of these import statements will allow you to use the File class?

Select one:

a. import java.FileIO.*;

b. import java.util.*;

c. import java.io.*;

d. import java.Files;

Question 14

Not yet answered

Marked out of 1.00

Flag question

Question text

When you get this error exception:

java.util.NoSuchElementException

From a scanner object declared as

Scanner fin = new Scanner(new File("data.txt"));

When your code executes

list[10] = fin.nextInt();

What does the error mean?

Select one:

a. reading past the end of the line in a file

b. tying to read a string into a int

c. tying to read beyond the end of a file

d. reading a file into the wrong element of an array

Question 15

Not yet answered

Marked out of 1.00

Flag question

Question text

Consider the following statements:

int[] hits = {5, 7, 9, 11, 13, 15};

What is the number of elements in the array hits.

Select one:

a. 15

b. 5

c. 0

d. 6

Question 16

Not yet answered

Marked out of 1.00

Flag question

Question text

Consider the following statements:

int[] hits = {5, 7, 9, 11, 13, 15};   //Line 1

public void print(int[] list)         //Line 2
{                                     //Line 3
    ...                               //Line 4
}                                     //Line 5

print(hits);                          //Line 6

In Line 6 what is being passed into the method call statement?

Select one:

a. A reference to the array object hits

b. 10

c. A copy of the array hits

d. The value of the elements of hits

Question 17

Not yet answered

Marked out of 1.00

Flag question

Question text

you are reading the following file data ( indicate where new lines are in the file)

10.6 Tom Jones

You already have a Scanner object named input that can read the file.

After the following code, what is the value in the variable x after this code runs?

double score = input.nextDouble();
String x = input.nextLine();

Select one:

a. "Tom Jones"

b. "Jones"

c. "Tom"

d. ""

Question 18

Not yet answered

Marked out of 1.00

Flag question

Question text

What import statement do you need to read files?

Select one:

a. import java.file.*;

b. import java.io.*;

c. import java.util.*;

d. import java.fileio.*;

Question 19

Not yet answered

Marked out of 1.00

Flag question

Question text

You see this error message:

unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown

type the exact code in the correct case in the area provided to fix this error within the main method declaration below:

public static void main(String[] args) Answer  {

Question 20

Not yet answered

Marked out of 1.00

Flag question

Question text

After this line of code:

File f = new File("data.txt");

If the file can be opened and read, then the expression f.canRead() will return the value of true.

Select one:

True

False

Question 21

Not yet answered

Marked out of 1.00

Flag question

Question text

Consider the boolean value after the followin code runs:

int [] list1 = { 1, 2, 3 };

int [] list2 = { 1, 2, 3 };

boolean areEqual = ( list1 == list2 )

The value of areEqual will now be true since the two arrays are equal.

Select one:

True

False

Question 22

Not yet answered

Marked out of 1.00

Flag question

Question text

if list is an array of integers, then you can use the special for each loop construct like this to print out the array.

foreach( int i in list) {

System.out.println(i);

}

Select one:

True

False

Skip Quiz navigation

Quiz navigation

Question1This pageQuestion2This pageQuestion3This pageQuestion4This pageQuestion5This pageQuestion6This pageQuestion7This pageQuestion8This pageQuestion9This pageQuestion10This pageQuestion11This pageQuestion12This pageQuestion13This pageQuestion14This pageQuestion15This pageQuestion16This pageQuestion17This pageQuestion18This pageQuestion19This pageQuestion20This pageQuestion21This pageQuestion22This page

Finish attempt ...

Time left 0:20:27

Explanation / Answer

Answered Everything Correctly, If u want any Further Explanation of anything or any doubts , Do ask me , plzz do Rate :)


1) A --> Both i) and ii)

2) D , out of bounds exception as alpha[5] is not in range.

3) C

4) C

5) A

6) A

7) D

8) A

9) D

10) C

11) A

12) C

13) C

14) D

15) D

16) A

17) A

18) B

19) public static void main(String []args) throws FileNotFoundException{
        //You can write any Code Here...and The exception will be thrown if there.
     }

20) True

21) False

22) False

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