Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 237

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

Moderator: admin

Post Reply
javiut
Posts: 37
Joined: Fri Oct 19, 2012 10:48 am
Location: Venezuela
Contact:

Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 237

Post by javiut »

I dont know if i already made this but i dont see it on the errata.

In page 237

10.5.3 Accesing static members from the same class.

I see

Code: Select all

System.out.println(InstanceCounter.printCount()+" "+InstanceCounter.count);
But this is a compilation error because the printCount() method is void and cannot be inside a System.out.println :thumbup:

Best regards.

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

Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 237

Post by admin »

You are right. It should be :
InstanceCounter.printCount()+" "+System.out.println(InstanceCounter.count);
Added to errata.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

javiut
Posts: 37
Joined: Fri Oct 19, 2012 10:48 am
Location: Venezuela
Contact:

Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 237

Post by javiut »

I think this would not work either.
InstanceCounter.printCount()+" "+System.out.println(InstanceCounter.count);
InstanceCounter.printCount() is void and you cannot append a value void.

This might work.
InstanceCounter.printCount();/*JUST LET THIS LINE PRINT ITSELF*/
System.out.println(InstanceCounter.count);

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

Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 237

Post by admin »

Right! What was I thinking!!
Updated.
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 45 guests