Question
1. After the following code is executed, the conditional expression s1 == s2 will evaluate to _____________ . String s1 = new String(Pears); String s2
1.
After the following code is executed, the conditional expression s1 == s2 will evaluate to _____________ .
String s1 = new String("Pears"); String s2 = new String("Pears");
Group of answer choices
false
true
2.
Which of the following will NOT result in a NullPointerException when str has the null value?
Group of answer choices
if ( str == null || str.isEmpty() ) { }
if ( str == null && str.isEmpty() ) { }
if ( str.isEmpty() || str == null) { }
if ( str.isEmpty() && str == null) { }
3.
Given the following code segment, which of the following are true?
String s1 = new String("Java"); String s2 = new String("Java"); String s3 = s2;
Group of answer choices
s2.equals(s3)
s1 == s2
s2 == s3
s1.equals(s2)
s1 == s3
4.
What is printed out?
char chr = 'B'; char out = 'W'; if ( chr == 'A') { out = 'X'; } if ( chr == 'B') { out = 'Y'; } if ( chr != 'A' || chr != 'B') { out = 'Z'; } System.out.print(out);
Group of answer choices
Y
W
X
Z
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started