About Question com.enthuware.ets.scjp.v6.2.534 :

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

Moderator: admin

Post Reply
balttoma
Posts: 1
Joined: Sun Jan 25, 2015 10:20 am
Contact:

About Question com.enthuware.ets.scjp.v6.2.534 :

Post by balttoma »

This question contains the following piece of code:
float f = 1.23f;
...
f = null;
...

Not to be offensive, but if I copy paste those two lines into any java IDE, you will get a compiler error - the 'float' variable can not be assigned a null value. An error in the question?

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

Re: About Question com.enthuware.ets.scjp.v6.2.534 :

Post by admin »

That is why the answer is 0 and what you say is exactly what the explanation says as well. "Further, you cannot assign null to primitives so this code will not compile."

HTH,
Paul.

pushpull
Posts: 14
Joined: Thu May 14, 2015 3:25 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.534 :

Post by pushpull »

I think the question is wrong. Or there is no good answer here.
How many objects will be eligible for garbage collection at the end of this method?

Code: Select all

public float method(float pf)
{
 float f = 1.23f;
 float o = f = pf;
 f = null;
 o = null;
 return 0;
}
There will be no end of this method, cause it just won't compile. It's true that there are no objects in this code, but still asking about end of the method is strange.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests