And it says correct answer is D with no explanation, but I tried it and answer is null!! Is it an error or something I don't understand?
And in question 27
Consider these 4 statements:
Boolean b = Boolean.parseBoolean("true"); Boolean c = Boolean.valueOf("true"); Float f = Float.valueOf("1011",2); Every wrapper has a public void toString(); method How many compilable or true (in case of 4) statements do you see ?
Answer A/0 B/1 C/2 D/3 E/4
Correct answer is C/2 and explanation is :
The first 2 are true. Via autoboxing 1) goes into the variable. The valueOf returns a Boolean object anyhow. A little trick to remember the return type is: if you hear the primitive in it (pareInt, pareShort, intValue, shortValue...) then it returns a primitive, else an Object
But for me ligne 4 is true too, because every object have a toString() method... Help
Every classes hast a public String toString() method from the Object class, hence is impossible that any object can implement a void toString() method because it doesn't override coreectly the toString method (bad return type)
SCJP 5, SCWCD 5
Joined: May 15, 2008
Ok thanks for question 27, I have not seen the void