Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/how-to-call-this-in-java-constructor
Question 51 / 297:  The following code contains one compilation error, where could it be?
public class Tester {

Tester() { } // line 1

static void Tester() { this(); } // line 2

public static void main(String[] args) { // line 3

Tester(); // line 4

}

}

A  At line 1, constructor Tester must be marked public like its class
B  At line 2, constructor call "this()" can only be called inside constructors
C  At line 3, compilation error, ambiguity problem, compiler can"t determine wether a constructor
Tester or method Tester is called
<< First < Previous Next > Last >>
Explanation:

a constructor call (super() or this() ) must be the first statement inside a constructor.

No constructor calls are allowed inside a method.

static void Tester() is a method not a constructor

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

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
Madison Christian
Start Quiz
Saylor Foundation
Start Quiz
Jugnu Khan
Start Quiz
Tess Armstrong
Start Quiz
Sarah Warren
Start Test
Anonymous User
Start Quiz
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>