This website is preserved for historical and scholarly reference and is no longer actively maintained.

QUIZ 2

August 26, 1998

#1. Given the following code:

String x = "Studebakers of yesteryear";
String y = "banana freak";
System.out.println(x.substring(0,4)
.concat(x.substring(15,16))
.concat(y.substring(0,1))
.concat(y.substring(8)));

What is printed out?



#2. Suppose you are given the following code:

String first = " Jane";
String last = " Doe";

where each String starts with some unknown number of spaces followed by a first or last name. Write a fragment of code that creates a String containing the initials of the first and last name and print it out.



Return to Eleanor Hare's home page.

Return to Department of Computer Science Home page.