Name & ID:_________________________________________________________

Quiz Q6

CS 100 – Summer 1999

Due: Tuesday July 27, 1999 10 minutes after the beginning of class

Question 1: If class A is abstract, and has an abstract method M, and class B is a nonabstract subclass of A, then what is required of B?

 

 

 

 

 

Question 2: Why does it make no sense to declare a method abstract static?

 

 

 

 

 

Question 2: What will be the output of the following program. (Be very, very careful.)

public class TrivialApplication {

public static void main(String args[]) {

int x = 1;

int y = 2;

C c = new C();

x = c.myMethod(x, y);

System.out.println("x = " + x + " y = " + y);

}

}

public class C {

public int myMethod(int x, int y) {

x = 3;

y = 4;

return y;

}

}

 

 

 

 

 

Question 3: Thinking algorithmically: describe binary search in 2 or 3 short sentences.