Page 1 of 1

About Question enthuware.ocajp.i.v7.2.1134 :

Posted: Mon Dec 23, 2013 11:40 am
by billclar
I'm unsure of how this is a correct answer:

String s = this.toString();

Instance members can refer to 'this' before the instance is created?

Re: About Question enthuware.ocajp.i.v7.2.1134 :

Posted: Mon Dec 23, 2013 1:21 pm
by admin
http://docs.oracle.com/javase/specs/jls ... jls-15.8.3
The keyword this may be used only in the body of an instance method, instance initializer, or constructor, or in the initializer of an instance variable of a class. If it appears anywhere else, a compile-time error occurs.
HTH,
Paul.

Re: About Question enthuware.ocajp.i.v7.2.1134 :

Posted: Fri Nov 01, 2024 10:09 am
by rasputyn
var a1 = new ArrayList<>();

this answer is not correct due the fact thar var is not allowed when defining an instance field.

Re: About Question enthuware.ocajp.i.v7.2.1134 :

Posted: Fri Nov 01, 2024 8:26 pm
by admin
You are right but I am unable to find this option in this question. Can you please post a screenshot of the complete question showing the full question id? Also, please mention the exam question bank that are you using.

Re: About Question enthuware.ocajp.i.v7.2.1134 :

Posted: Sun Nov 03, 2024 5:17 am
by rasputyn
I attached two screenshots showing the correct answers and the question bank information (i'm using last version):
QuestionID: enthuware.ocpjp.v21.2.3220

Re: About Question enthuware.ocajp.i.v7.2.1134 :

Posted: Sun Nov 03, 2024 9:45 am
by admin
Got it.
thank you for your feedback!

Re: About Question enthuware.ocajp.i.v7.2.1134 :

Posted: Sun Nov 03, 2024 10:35 am
by rasputyn
:cheers: