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?
About Question com.enthuware.ets.scjp.v6.2.534 :
Moderator: admin
-
- Posts: 1
- Joined: Sun Jan 25, 2015 10:20 am
- Contact:
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.534 :
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.
HTH,
Paul.
-
- Posts: 14
- Joined: Thu May 14, 2015 3:25 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.534 :
I think the question is wrong. Or there is no good answer here.
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.
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;
}
Who is online
Users browsing this forum: No registered users and 14 guests