Which code snippet will output "Yes!" when two strings s1 and s2 are equal?
A) if (s1 = s2)
{
System.out.println("Yes!") ;
}
B) if (s1 == s2)
{
System.out.println("Yes!") ;
}
C) if (s1.equals(s2) )
{
System.out.println("Yes!") ;
}
D) if (s1.compareTo(s2) == 1)
{
System.out.println("Yes!") ;
}
Correct Answer:
Verified
Q25: What is the output of the following
Q26: Assuming that the user enters 60 as
Q27: What is the problem with the following
Q29: Suppose you want to write an if
Q30: Assuming that a user enters 5 as
Q30: The two strings "Aardvark" and "Aardvandermeer" are
Q33: The switch statement in Java
A) is like
Q53: Consider a situation where multiple if statements
Q74: An if statement inside another if statement
Q88: Which of the following options is a
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents