Quiz Yourself on Boolean Expressions and if Statements
Attempt the following quiz to test your understanding of boolean expressions and if statements.
1
Consider the following code:
String s1 = "Sorry", s2 = "sorry", s3 = "shelves";
boolean answer1 = s1.compareTo(s2) == 0;
boolean answer2 = !(s1.compareTo(s3) < 0);
boolean answer3 = !(s1.substring(2,3).equals(s2.substring(3,4)));
boolean answer4 = !(s2.length() < s3.indexOf("e"));
Which boolean variables in the above code are initialized to false
?
A)
answer1
B)
answer2
C)
answer3
D)
answer4
Question 1 of 190 attempted
Get hands-on with 1400+ tech skills courses.