Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/what-can-java-static-methods-make-references-to
Question 19 / 297:  What is the result of compiling and running the following code?
public class Tester {

static int x = 4;

int y = 9;

public Tester() {

System.out.print(this.x); // line 7

printVariables();

}

public static void printVariables() {

System.out.print(x); // line 12

System.out.print(y); // line 13

}

public static void main(String... args) { // line 16

new Tester();

}

}

A  Compile error at line 7 (static x must be only accessed inside static methods )
B  Compile error at line 13 (static methods cant make reference to non-static variables )
C  Compile error at line 16 (invalid argument type for method main )
D  49
E  Compile error at line 12 (must access x by writing Tester.x)
<< First < Previous Next > Last >>
Explanation:

static methods cannot make references to non-static variables

Exam Home Page
https://www.jobilize.com/java-certification-questions

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
Madison Christian
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>