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

22. Which code snippet calculates the sum of all the even elements in an array v

ID: 3685245 • Letter: 2

Question

22.

Which code snippet calculates the sum of all the even elements in an array values?

Select one:

a.

b.

c.

d.

23.

Consider the following method:

Which statement is correct about the code?

Select one:

a. The method works perfectly

b. The method returns a random number

c. The method return type should be changed to int[]

d. The method has a bounds error when the array size is too large

24.

Which one of the following is a valid signature of a method with an integer two-dimensional array parameter of size 10 x 10?

Select one:

a. public static void func(int[][] arr)

b. public static void func(int[10][] arr)

c. public static void func(int[][10] arr)

d. public static void func(int[10][10] arr)

25.

Babbage’s machine for automatically producing printed tables was called

Select one:

a. the slide rule.

b. the difference engine.

c. the mechanical calculator.

d. the cog wheel.

26.

Which code snippet calculates the sum of all the elements in even positions in an array?

Select one:

a.

b.

c.

d.

27.

Consider the following code snippet:

What is the value of numarray[1][2] after the code snippet is executed?

Select one:

a. 2

b. 5

c. 3

d. 4

28.

Consider the following code snippet:

Which statement sorts the data array in ascending order?

Select one:

a. data = Arrays.sort();

b. Arrays.sort(data);

c. data = Arrays.sort(data.length);

d. data = Arrays.sort(data);

29.

When a Java program terminates and reports an exception, the error message contains which pieces of useful information?

I. The compile and revision control history of the source code changes that caused the error

II. The name of the exception that occurred

III. The stack trace

Select one:

a. I, II

b. I, III

c. II, III

d. I, II, III

30.

When an integer literal is added to an array list declared as ArrayList<Integer>, Java performs:

Select one:

a. casting

b. trimming

c. auto-boxing

d. auto-fixing

Explanation / Answer

22)

ans- a

23)

Ans-c. The method return type should be changed to int[]

24)

Ans-a. public static void func(int[][] arr)

25)

Ans-b. the difference engine.

26)

Ans- d.

27)

‘Ans- b. 5

28)

Ans-b.

Arrays.sort(data);

29)

Ans- a. I, II

30)

Ans- c. auto-boxing

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