Helsingin yliopisto / Tietojenkäsittelytieteen laitos / 581258-1 Johdatus ohjelmointiin
Copyright © 1998 Arto Wikla. The use of this material is only allowed for studying purposes of private persons. Any other use of this material, such as commercial or other courses, is forbidden.


581258-1 Introduction to Programming: 2. exam 17.12.1998/AW

This is an English version of the examination, not a translation of Finnish questions. Some of the questions are different.

Write on top of every answering paper the name of the course, the date of the examination, your name, your date of birth and your signature.

You are allowed to use the tools of the class Read (in Finnish Lue) when writing your programs.

  1. Explain the following concepts shortly and precisely:
  2.    primitive type
       reference type
       overloading
       overriding
       package
                                                                  (5 points)
    
    
  3. In a game play each player has a name, the description of his/her role in the game, his/her goodness as an integer -10...10, and his/her strength as a decimal value 0.0...1.0. The weight of a player in "defending the good" is calculeted with formula goodness * strength
  4.                                                              (8 points)
    
    
  5. One of your friends, taking part to this course, has not totally understood the idea of "classes" and "objects". He/she hasn't even got the idea, why he/she should understand these concepts. Help your friend and write him/her an explanation of the matter. Remember that good examples are important in learning. Your explanation will be evaluated from the point of view of your friend. So do not write to your teacher, he/she already knows it!
  6.                                                               (5 points)
    
  7. You are given a class called InpFile for reading input files. The class has a constructor:
  8. The class has a method for reading lines:

    By using this class, write a program that asks the user for the name of the input file, a character to be replaced (oldChar), and a replacing string (newString). Then the program prints the file on the screen, modified so that all oldChar characters are replaced by the string newString.

                                                                  (8 points)
    










Merry Christmas!