Re: About Question enthuware.ocajp.i.v8.2.1414 :
Posted: Sat Apr 23, 2016 3:01 pm
Hi All, this are quotes from the mock exam
"Boolean class has two static helper methods for creating booleans - parseBoolean and valueOf. Boolean.parseBoolean(String ) method returns a primitive boolean and not a Boolean object "
Boolean n = Boolean.parseBoolean("true");
System.out.println( n ); // => true
System.out.println( n.getClass() ); // => class java.lang.Boolean
boolean nn = Boolean.parseBoolean("true");
System.out.println( nn ); // => true
So how come in the answer says that it only returns primitive type.
or is because, when it says it returns a primitive type. it actually returns "true", and is the same thing as doing
Boolean n = true;
"Boolean class has two static helper methods for creating booleans - parseBoolean and valueOf. Boolean.parseBoolean(String ) method returns a primitive boolean and not a Boolean object "
Boolean n = Boolean.parseBoolean("true");
System.out.println( n ); // => true
System.out.println( n.getClass() ); // => class java.lang.Boolean
boolean nn = Boolean.parseBoolean("true");
System.out.println( nn ); // => true
So how come in the answer says that it only returns primitive type.
or is because, when it says it returns a primitive type. it actually returns "true", and is the same thing as doing
Boolean n = true;