Exam Object Oriented Software Development CME 1, WS 2010/11 09.02.2011
Exam Object Oriented Software Development CME 1, WS 2010/11 09.02.2011
: ____________________
1. Please write your name and Matrikelnummer on each sheet of paper. Sheets without
name and Matrikelnummer will not be graded.
2. Please use the provided sheets for writing down your solutions. Other sheets will not
be graded.
3. Please check that the exam sheets are complete.
4. Please write clean and clearly readable. Unreadable answers will not be graded. Please
do not use a pencil or red ink.
5. Students are allowed to use an English dictionary and the Handout of 4 DIN A4 Pages
Exercise 1 2 3 4 Sum
Points 19 36 12 12 79
Reached Points
Final Result
Good Luck!
__________________________________________________________________________________________
Page 1 von 1
Name: _____________________________________ MatrikelNr.: ____________________
demo.doSomething();
}
Please mark the line of code where the compiler error is. What should be done to correct the
code? (4 Points)
__________________________________________________________________________________________
Page 2 von 2
Name: _____________________________________ MatrikelNr.: ____________________
void wash();
}
int i, j, k;
double d = 5.52;
i = (int)d;
j = i;
k = i + j;
__________________________________________________________________________________________
Page 3 von 3
Name: _____________________________________ MatrikelNr.: ____________________
h) Please provide the definition of Enumeration class, which represents the day of week
property of the Date. Possible values of Enum are: Monday, Tuesday, Wednesday, Thursday,
Friday, Saturday and Sunday. (3 Points)
__________________________________________________________________________________________
Page 4 von 4
Name: _____________________________________ MatrikelNr.: ____________________
a) Translate the given UML Diagram to the Java code. Data types and access modifiers are
provided. Methods should only contain the implementation that is necessary for compilation
(no business logic). Please notice, that the relationship between class Store and Product
has also an access modifier. Constructor of the class Product should initialize the attributes
productID, description and price with the values of the parameters. Take attention
that the getProductInfo() - method is overwritten in each subclass of Product.
(16 Points)
b) Please implement the printAllProducts()- method. The method should give out the
list of all products, represented by the relationship between the classes Store and Product,
to the console in the following format: “The %product% %description% with
ID: %productID% costs %price% Euro.”
%product% - takes the value “IronTool” or “Toy” dependent on which type of product is it
%description% - the value of the attribute description
%productID% - the value of the attribute productId
%price% - the value of the attribute price
(8 Points)
__________________________________________________________________________________________
Page 5 von 5
Name: _____________________________________ MatrikelNr.: ____________________
c) Additional to the stuff, defined in UML diagram, following constant is given in the
Product class:
public static final double SALES_TAX = 19.0;
Please implement setPrice(double basePrice)- method as follows: the price of the
product can be calculated as a sum of the base price, which is given by a parameter of the
method setPrice(), and 19% of the base price for the sales tax. This value should be set
as a value of the attribute price in the Product class. Take care, that the base price cannot be
negative.
(4 Points)
__________________________________________________________________________________________
Page 6 von 6
Name: _____________________________________ MatrikelNr.: ____________________
__________________________________________________________________________________________
Page 7 von 7
Name: _____________________________________ MatrikelNr.: ____________________
__________________________________________________________________________________________
Page 8 von 8
Name: _____________________________________ MatrikelNr.: ____________________
__________________________________________________________________________________________
Page 9 von 9
Name: _____________________________________ MatrikelNr.: ____________________
__________________________________________________________________________________________
Page 10 von 10
Name: _____________________________________ MatrikelNr.: ____________________
a) Redesign this model (provide the new UML class diagram) in order to avoid the code
redundancy.
(4 Points)
Please integrate this class in your class hierarchy above and avoid code redundancy. Make
sure that Bird and Aircraft classes have the fly()- method in any case.
(6 Points)
c) What are the differences (write down at least 2 of them) between abstract classes and
interfaces?
(2 Points)
__________________________________________________________________________________________
Page 11 von 11
Name: _____________________________________ MatrikelNr.: ____________________
__________________________________________________________________________________________
Page 12 von 12
Name: _____________________________________ MatrikelNr.: ____________________
__________________________________________________________________________________________
Page 13 von 13
Name: _____________________________________ MatrikelNr.: ____________________
__________________________________________________________________________________________
Page 14 von 14
Name: _____________________________________ MatrikelNr.: ____________________
__________________________________________________________________________________________
Page 15 von 15