98-388 Exam QuestionsBrowse all questions from this exam

98-388 Exam - Question 34


HOTSPOT -

You need to evaluate the following code. Line numbers are included for reference only.

Exam 98-388 Question 34

Use the drop-down menus to select the answer choice that answers each question based on the information presented in the code.

NOTE: Each correct selection is worth one point.

Hot Area:

Exam 98-388 Question 34
Show Answer
Correct Answer:
Exam 98-388 Question 34

Discussion

6 comments
Sign in to comment
lulzosad
Jun 17, 2021

I checked everything. Correct answer is: 55 56 Out of scope.

oussemadev
Nov 10, 2021

he said line 10 not 11

oussemadev
Nov 10, 2021

Line 9*

oussemadev
Nov 10, 2021

Line 9*

MuzM
Jun 25, 2020

wouldnt it be out of the scope for the last one? because the for loop has it's own scope and the maximum value cnt reaches is 9?

mtmoore
Aug 25, 2020

At line 11 anum would be 56 because anum++ already ran and cnt doesn't exist when line 6 executes.

Girul
Oct 6, 2021

55 55 Out of scope. El método "add" tiene como parámetro "anum" del tipo primitivo "int". Un parámetro de tipo primitivo siempre es pasado por copia, no por referencia, por lo tanto, aunque se altere dentro del método, al acabar el método el valor queda como estuviera al principio, sin alteaciones. Por eso la segunda respuesta es 55, no 56, ni 63. As for the variable "cnt", it is local to the "for" loop, and outside its keys it no longer exists.

ahm3edtrig
Apr 4, 2021

55 63 out of scope

estherjq
Apr 16, 2021

55 56 *the new anum is not saved, it is 55 when a new loop start) 10 (not sure, but i think when cnt reached 10, it ends the loop so code can run line06 which is out of scope for the loop) public static void main(String []args){ int anum = 55; for (int cnt = 0; cnt < 10; cnt++){ add(anum); System.out.println("line05 index" + cnt + " "+ anum); } System.out.println(anum); } public static void add(int anum){ anum++; System.out.println("line11 " + anum); }