University of Helsinki / Dep. of Computer Science / Introduction to Programming / Copyright © 2001 Arto Wikla.

581325-0 Introduction to Programming, course examination 12.11.2001/AW

Write the name of the course, the date of the exam, your name, personal number and signature on each paper. Write each answer on a separate paper! You are allowed to use the tools of the Lue-class (or Read-class) for reading the input. Each question is worth 10 points.
  1. Explain briefly yet exactly the following concepts: expression, statement, constructor, accessor, index.

  2. A ship's direction can have the values 0...359 degrees and its speed can be -5.0...30.0 knots. A negative speed means the ship is backing up. Design the Ship class that is to be used with the following methods:

    The data structures of the Ship class are to be hidden from the user of the class.

  3. Using the class from the previous exercise, create an application Skipper with which the ship can be driven. The keyboard user interface is as follows (the interface is slightly clumsy, because each command must be given with the return key):

    After each operation, the program prints the state of the ship.

  4. "What in the world are those method things?", your friend wails when hearing your stories of the course Introduction to Programming. Your friend has programmed enough to know simple variables, expressions and statements. "What the heck are 'parameters', who is 'calling' and whom, why?, he goes on in despair. Help your friend understand what it is all about. Draw up a written description (1 exam paper at the most). Keep in mind that examples aid learning. In the evaluation of your answer, we will take into account the intended reader of the description, so do not write for the examinator, who already knows about it, but for that friend!

  5. Implement the following service as an interactive program. In the mornings, the program is given character strings (String values) as input in random order. The end of a character string is announced by the input "end" as the final character. There are never more than one thousand strings. During the day, the program is often asked whether a certain character string (String value) was among the morning input. In the evening, the program is closed by the input "night". For the sake of efficiency, the search for character strings has to be programmed with a binary search