Name: ________________________________

CSE373 Spring Quarter
University of Washington
Miniquiz #2
April 4, 2005
Closed book, closed notes, closed neighbor; no calculators
1 point per part except as noted

 
What is the final value of s3 in the following?

String s1 = "Mt.";

String s2 = "St. Helens";

String s3 = s1 + s2;

s2 = "Rainier";

  1. "St. Helens"
  2. "Rainier"
  3. "Mt.St. Helens"
  4. "Mt.Rainier"
  5. "s1 + s2"
notes and answers 
 
.
What is the value printed by the following?

int[] nums;  //line 1

nums[0] = 10; //line 2

nums[1] = 11; //line 3

nums[0] = nums[1]; //line 4

System.out.println(nums[0]); //line 5

  1. 10
  2. 11
  3. won't get to line 5 because of a compile error on line 2
  4. won't get to line 5 because of a run-time error on line 2
Some compilers will give you an error: "local variable may not have been initialized." If not, then there would be a run-time error.
 
.
StudentData stu; //line 1

stu = new StudentData("Rodney", 03277); //line 2

boolean enrolled = stu.checkStatus();  //line 3

stu.printout(); //line 4

  1. Which line or lines contain a declaration? __1, 3
  2. Which line or lines create an object? ___2
  3. Which line or lines send a message to an object? __3, 4.  2 won't be scored incorrect, although technically there is no object to send a message to until after the constructor has executed.
notes and answers 
 
Assuming that a string variable named fun has been declared and initialized, write an expression which puts the first character of that string into the variable first.

char first;

first = fun.charAt(0);

notes and answers 
 
.
In Homework #1, what are the arguments of the method normalize?
  1. (String[] dictionary) 
  2. (String [] dictionary, String originalWord)
  3. (List dictionary, String originalWord)
  4. (String originalWord)
  5. (char[] originalWord)
notes and answers 
 
.
If Homework #1 is too much for you, you may...
  1. work with a partner
  2. outsource it to India
  3. outsource it to WSU
  4. turn it in a day late with a small penalty
  5. turn it in a week late with a small penalty
  6. suffer
notes and answers 
 
.
(free bonus point)

The material in the Mathematical Background handout was...

  1. already completely familiar
  2. mostly familiar
  3. mostly unfamiliar
  4. completely unfamiliar
  5. I haven't had time to read it yet but plan to do so very soon
notes and answers