Im working on this question, and i dont know if what i tried to solve is right or wrong :s, hope to get some advice from you guys:
You have an interface Student that declares two methods:
public String getMasterProgram()
public String getMatriculationNr().
A class StudentImplementation that implements this interface.
A class HiWi (paid worker at university) that implements two methods:
public String getContractNr()
public String getHoursPerMonth()
Some students are at the same time HiWis.
i. Please describe where you would use composition and where inheritance and write down the new class.
my answer: - Inheritance: is the ability to derive one class from another.
- composition :where one class has a data member that is an instance of the other class.
- new class: ?? (Im hoping to get some help with this part :S)
ii. Write the complete declaration for the class WorkingStudent.
my answer: -I’ am assuming that WorkingStudent, inherits from HiWi ...and im not sure if what i did below is correct......therefore:
Expand|Select|Wrap|Line Numbers
- Class WorkingStudent extends HiWi{ //class body}
outofmymind