Exam 1z0-808 All QuestionsBrowse all questions from this exam
Question 85

Given:

And given the commands:

What is the result?

    Correct Answer: C

    The key to answering this question lies in how the Boolean class handles string inputs. When the Boolean.valueOf(String s) method is called, it returns true if the string is non-null and equal to 'true' (ignoring case); otherwise, it returns false. The second line in the main method constructs a Boolean object directly from the string 'null'. The Boolean constructor also treats any string other than 'true' as false. When the program is executed with '1' and 'null' as arguments, neither '1' nor 'null' equates to 'true', so both boolean 'a' and boolean 'b' will be false. Therefore, the output is 'false false'.

Discussion
iSnoverOption: C

Correct is C, The default valor of a boolean type is false. When the valor is null, in boolean case, it is automatically transformed into false. In the line 2, as the boolean value was not started, so it is false too. Answer False False.

Joker74Option: C

if we pass other then true(equals ignore case) as a Boolean argument then it is referred as false.

BelloMioOption: C

boolean valueOf(string s) The Boolean returned represents a true value if the string argument is not null and is equal, ignoring case, to the string "true" https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#valueOf-boolean- Which means it returns false when a string is equal to "1"

dsmsOption: C

answer is: false false

winfred_luOption: C

false false

Vicky_65Option: C

C is the correct answer

akbiyikOption: A

java Test 1 null 1 and null are Strings because args type is String[]. public static Boolean valueOf(String s) { return parseBoolean(s) ? TRUE : FALSE; } If the specified boolean is true, then the string "true" will be returned, otherwise the string "false" will be returned. In this case, if the value is not true, all other String values return false.

anmoldev2javaOption: C

c is ans

carlosworkOption: C

Answer is C. Remember to run in command line "java Test 1 null". boolean a = new Boolean(Boolean.valueOf(args[0])); boolean b = new Boolean(args[1]); System.out.println( a + " " + b );