Question 129 / 297:  What is the result of compiling and running the following code?
public class Tester {

final short s = 12; // Line 3

static void swap( Tester obj) {

obj.s = 11; // Line 6

}

public static void main(String[] args) {

final Tester obj1 = new Tester();

swap(obj1);

System.out.print(obj1.s); // Line 12

}

}

A  11
B  12
C  Compilation error at line 3
D  Compilation error at line 6
E  Compilation error at line 12
<< First < Previous Next > Last >>
Explanation:

Final variables cannot be reassigned

Exam Home Page
Ask
Kimberly Nichols
Start Test
Subramanian Divya
Start Quiz
Vanessa Soledad
Start Exam
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>