FHTW Berlin

FHTW Berlin
Fachbereich 4
Internationale Medieninformatik
PROG1: Programmierung I
Wintersemester 02/03


Examination handout



The examination is scheduled for Friday, Jan 24, 2003 from 13.45-15.15 (90 minutes length) in room HG 130.

It will cover material from the lectures and the lecture notes up to and including java.awt and laboratories up to and including the Scribbler. You may bring any notes or books you wish, as well as an English-German dictionary. You may bring refreshments, but no electronical devices, no telephones, no radios, no computers are allowed. If I catch anyone cheating (and I have eyes in the back of my head), you will be given an automatic failing grade for the course.

The format of this exam will be negative multiple choice and essay.

In negative multiple choice each question has exactly one correct answer and five incorrect ones. Instead of getting points for picking the right answer, you get points for eliminating the other (wrong) answers. Each wrong answer that you cross out is worth +2 points. However, if you cross out the right answer, that is worth -10 points. THis means that if you cross out all six answers, you get (5 * 2) -10 = 0 points.

This way, you can get full credit if you know which answer is correct by crossing out all of the incorrect answers. You can also get partial credit if you are sure that one of the answers is incorrect, even if you don't know which other answer is the correct one.

I will consider an answer to be crossed out if you have put an X through the letter at the beginning of the answer.

For example:

Question 0

What is the name of the professor teaching this course? Cross off the wrong answers
  1. Kathrin Freese-Kriesel
  2. Pamela Anderson
  3. Debora Weber-Wulff
  4. Lynn Andrea Stein
  5. Karla Buchholz
  6. Kai-Uwe Barthel
If you were pretty sure that the professor was a woman, you could cross off Kai-Uwe Barthel. That would be worth 2 points.

Similarly, you could realize that the woman teaching didn't look quite like Pamela Anderson, so now you are up to 4 points.

If you reach this point and are stumped, you can stop here. You would receive 4 points out of a possible 10.

If you remember that Karla Buchholz is the teacher for English, not Programming, you'd get another 2 points: 6/10.

And if you now decide that you've heard the name Lynn Andrea Stein so often, she must be the professor, you could eliminate Margarita Esponda and Debora Weber-Wulff.

Unfortunately, this would get you another +2 for Kathrin Freese-Kriesel, who is the department director, but a -10 for crossing out the name of the professor teaching the course, for a total of -2. It's a bad idea to eliminate a choice unless you are sure that it is wrong.

Another one?
 

Question 0.5

What is the title of the draft textbook for this course?
  1. Interactive Programming in Java
  2. Introduction to Interactive Programming
  3. The Community Model of Programming
  4. Constituting a Community
  5. Java Programming: It's just Syntax
  6. Programming for Poets
  7. Unstructured Misinterpretation of Computer Programs
Now let's get on to Java questions!


Question 1

Assume that the following classes have been defined.
   public class Basic {
       public void printIt() {
           Console.println("Basic method");
       }
   }

   public class Extended extends Basic {
       public void printIt() {
           Console.println("Extended method");
       }
   }
If the following line of code is executed, what is printed?
  1. Nothing; the program won't compile because the classes have illegal syntax.
  2. Nothing; the program compiles, but execution causes an error.
  3. Just Basic method.
  4. Just Extended method.
  5. First Basic method

  6. then Extended method.
  7. First Extended method

  8. then Basic method.

Question 2

If we have already declared then the problem with the expression is that
  1. it is redundant to compare a boolean to true.
  2. the underlined item changes the value of isHappy.
  3. isHappy can't be assigned true; it's already false.
  4. the underlined item is not an expression; it's a statement.
  5. isHappy isn't properly declared.
  6. true isn't properly declared.

Question 3

If we are inside the act method of a NodeBehavior with parameters ins and outs -- that is, inside a method with the declaration -- and ChannelInputStream has a readObject method specified as then the type of the expression ins[3].readObject() is
  1. 3.
  2. ChannelEmptyException.
  3. ChannelInputStream.
  4. Object.
  5. null.
  6. void.

Question 4

Which of the following could be a legal Java constructor method for class Classic? You may assume that Classic defines any necessary methods or fields.
  1. public Classic {

  2.     super();
    }
  3. public void Classic () {

  4. }
  5. Classic (int i) {

  6.     this.number = i;
        super();
    }
  7. Classic () {

  8. }
  9. public Classic (int i) {

  10.     this.number = i;
        return i;
    }
  11. public Classic () {

  12.     return new Classic();
    }

Question 5

Assume that the following class has been defined: Which of the following statements is true?
  1. new Test() has type Object.
  2. Line 4 is nonsensical (that is, not legitimate Java).
  3. The setName method is redundant because you can always use the name field directly.
  4. If foo is an appropriately declared label and we assign foo = new Test( "foo" ), then foo.getName has the same value as foo.
  5. If foo is an appropriately declared label and we assign foo = new Test( "foo" ), then foo.setName( "bar" ) does not change the value bound to the label foo.
  6. If foo is an appropriately declared label and we assign foo = new Test( "foo" ), then foo.name is never legal Java.

You will find a number of questions like the ones above!

Then we have the essay part, there are questions like this here. Write in complete sentences, in English or German.

Question 1 (10 points): What is a class?
Question 2 (10 points): Can a class have more than one constructor? If so, how are they differentiated?
Question 3 (10 points): What is the difference between int i; and Integer j; ?
Question 4 (10 points): What is the difference between a while and a for loop?
Question 5 (60 points): Explain to a Martian how to solve the Spirograph exercise.
 


This course is an adaption for the Fachhochschule für Technik und Wirtschaft , Berlin by Prof. Dr. Debora Weber-Wulff of a part of Prof. Dr. Lynn Andrea Stein's Rethinking CS101 project produced while she was at the MIT AI Lab belonging to the Department of Electrical Engineering and Computer Science (EECS) at the Massachusetts Institute of Technology. The copyright for all materials belongs to Lynn Andrea Stein, this adaptation is used by permission. All rights reserved.
A textbook is in preparation by Morgan Kaufmann Publishers


Questions or comments: <weberwu@fhtw-berlin.de>