Page 1 of 1

About Question enthuware.ocajp.i.v8.2.1417 :

Posted: Fri May 27, 2016 4:03 pm
by JaredTse
Hi All,

I am a bit confused about this question. Should't the answer include

parseBoolean(boolean )

Since its a member of the Boolean class. I understand is overloaded but how can you tell which one is the correct to pick ?

Thanks

Re: About Question enthuware.ocajp.i.v8.2.1417 :

Posted: Fri May 27, 2016 9:11 pm
by admin
Boolean class doesn't have any parseBoolean method that takes boolean as an argument. So I am not sure what is the confusion.
-Paul.

Re: About Question enthuware.ocajp.i.v8.2.1417 :

Posted: Sat May 28, 2016 5:27 am
by JaredTse
Hi Paul,

You are right, I have opened the Boolean class and searched for a method called parseBoolean(boolean ) that takes a boolean as argument and did not find any. I assumed that it had an overloaded version, which takes boolean. Obviously I was wrong. But I did find the sting version.

Code: Select all

    public static boolean parseBoolean(String s) {
        return ((s != null) && s.equalsIgnoreCase("true"));
    }
Thanks

Re: About Question enthuware.ocajp.i.v8.2.1417 :

Posted: Fri Mar 04, 2022 2:39 pm
by cronicmanga
The first explanation says there are 2 constructors, - Boolean(String) and Boolean(boolean), but it also marks Boolean(Boolean ) as a wrong answer. Is this like a difference between Boolean and boolean?

Re: About Question enthuware.ocajp.i.v8.2.1417 :

Posted: Fri Mar 04, 2022 9:42 pm
by admin
yes, right.