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
About Question enthuware.ocajp.i.v8.2.1416 :
Moderator: admin
-
- Posts: 8
- Joined: Mon Jul 29, 2019 11:25 am
- Contact:
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1416 :
Because the question explicitly asks you to pick options that yield a Boolean wrapper object.
The question is not about valid assignment. Boxing/unboxing happens in an assignment and so a wrapper may be assigned to a primitive variable and vice-versa but that is not what this question is asking about.
The question is not about valid assignment. Boxing/unboxing happens in an assignment and so a wrapper may be assigned to a primitive variable and vice-versa but that is not what this question is asking about.
If you like our products and services, please help us by posting your review here.
-
- Posts: 8
- Joined: Mon Jul 29, 2019 11:25 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1416 :
***Boxing/unboxing happens in an assignment*** - it was not clear for me.
I understood. Thanks you!!!
I understood. Thanks you!!!
Who is online
Users browsing this forum: No registered users and 73 guests