About Question enthuware.ocajp.i.v8.2.1416 :
Posted: Fri Aug 02, 2019 1:51 pm
Hello! Please explain to me.
Answer B: Boolean.parseBoolean("true")
Although this will return true but it is still not a valid answer because parseBoolean returns a primitive(!!!!!) and not a Boolean wrapper object.
But why code below doesn't call any error?
Boolean b1 = Boolean.parseBoolean("true"); // There is Boolean. It is wrapper!? Why it is working?
boolean b2 = Boolean.parseBoolean(" _true_ ");
System.out.println(b1); //true
System.out.println(b2); // false
Answer B: Boolean.parseBoolean("true")
Although this will return true but it is still not a valid answer because parseBoolean returns a primitive(!!!!!) and not a Boolean wrapper object.
But why code below doesn't call any error?
Boolean b1 = Boolean.parseBoolean("true"); // There is Boolean. It is wrapper!? Why it is working?
boolean b2 = Boolean.parseBoolean(" _true_ ");
System.out.println(b1); //true
System.out.println(b2); // false