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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!