Medium Multiple Choice QuestionsΒΆ

These problems are similar to those that you will see on the AP CS A exam.

4-8-1: After the following code is executed, which of I, II and/or III will evaluate to true?

String s1 = "xyz";
String s2 = s1;
String s3 = s2;

I.   s1.equals(s3)
II.  s1 == s2
III. s1 == s3






4-8-2: What is output from the following code?

String s = "Georgia Tech";
String s1 = s.substring(0,7);
String s2 = s1.substring(2);
String s3 = s2.substring(0,3);
System.out.println(s3);






4-8-3: Given the following code segment, what is the value of s1 after the code executes?

String s1 = "Hi There";
String s2 = s1;
String s3 = s2;
String s4 = s1;
s2 = s2.toLowerCase();
s3 = s3.toUpperCase();
s4 = null;