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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
billclar
Posts: 2
Joined: Fri Dec 20, 2013 10:59 am
Contact:

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

Post 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?

admin
Site Admin
Posts: 10066
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 222 guests