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"
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.
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 );
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.
if we pass other then true(equals ignore case) as a Boolean argument then it is referred as false.
upvoted 2 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
BelloMio
1 month, 2 weeks agodsms
11 months, 1 week agowinfred_lu
1 year agoVicky_65
1 year, 3 months agoakbiyik
1 year, 7 months agoanmoldev2java
1 year, 8 months agocarloswork
1 year, 9 months agoiSnover
1 year, 9 months agoJoker74
1 year, 10 months ago