[HD Pg 192, Sec. 8.3.3 - accessing-static-members-from-the-same-class]

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

Moderator: admin

Post Reply
Username987654
Posts: 95
Joined: Sat Dec 26, 2015 6:37 pm
Contact:

[HD Pg 192, Sec. 8.3.3 - accessing-static-members-from-the-same-class]

Post by Username987654 »

Code: Select all

new InstanceCounter();
new InstanceCounter(); //accessing static method through an implicit reference to
an instance
new InstanceCounter().printCount(); //accessing count through the class name
System.out.println(InstanceCounter.count);
should be

Code: Select all

new InstanceCounter(); 
new InstanceCounter().printCount();//accessing static method through an implicit reference to an instance 
System.out.println(InstanceCounter.count);//accessing count through the class name
?

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

Re: [HD Pg 192, Sec. 8.3.3 - accessing-static-members-from-the-same-class]

Post by admin »

Right. Added to the errata.
thank you for your feedback!

natasci
Posts: 6
Joined: Fri Mar 15, 2019 4:40 am
Contact:

Re: [HD Pg 191, Sec. 8.3.2 - accessing-static-members-from-the-same-class]

Post by natasci »

Code: Select all

class TestClass{
	public static void main(String[] args){
		Foo f = null;
		f.baz();
	}
}
at page 190 baz() was declared as private static method in class Foo and therefore is not visible in TestClass

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

Re: [HD Pg 192, Sec. 8.3.3 - accessing-static-members-from-the-same-class]

Post by admin »

Right. Added to the errata.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests