CSC

 

Example questions for part II of the exam

All assignments from övningar are possible exam questions.
  • Programming assignments will occur, often with design patterns.
  • Question nr 4 from Övning 4. English question is available.
  • Questions 1-4 from Övning 5 except to write the DTD. To write XML consistent with a given DTD is a possible exam question.
  • Questions 1-5 from Övning 6 The questions are not in english!
  • In a library you find the classes FantasyMirror and MagicMath. The two classes cover almost all the functionality you need for a new class in the adventure game that you are planning to write. Your first plan is to write a new class that inherits from both library classes. You realize that Java does not support multiple inheritcance. How do you write a class that uses the functionality of the two library classes ?
All design patterns metioned in the course lectures may appear in the exam but no others. In part II of the exam there may be more detailed questions than in part I, e.g. describe a pattern, its purpose and participants or to choose a pattern for a particular problem.
  • Below are two attempts to implement the Singleton pattern. Both contain a mistake. Explain what is wrong with each of them. Look at the classes separately. If you look at them together it is an easier task.
    class Singleton {
        private Singleton theInstance = new Singleton();
        
        private Singleton() { }
    
        public static Singleton getInstance() {
            return theInstance;
        }
    }
    
    
    class Singleton {
        private static Singleton theInstance = new Singleton();
        
        private Singleton() { }
    
        private static Singleton getInstance() {
            return theInstance;
        }
    }
    

Sidoansvarig: <ann "at"nada.kth.se>
Last update: may 23rd 2010
Tekniskt stöd: <webmaster@nada.kth.se>