Key Midterm Exam v2
Key Midterm Exam v2
Q1: Multiple Choices: each question has exactly one correct answer (15 point).
3 If there is exception or not in the code, the _______ block will be executed.
A. try C. finally
B. catch D. final
5 ____keyword is used in the relations between the interfaces and other interfaces.
A. implements C. extends
B. import D. none of the above
7 Which of these represents the Has-a relationship between Car and engine?
A. class engine extends Cat {} C. class engine extends Car { }
B. class Engine { Car c;} D. class Car { Engine e;}
Q5: Consider that, we have UML diagram as the following (25 point)
Date Pet
<<interface>>
- Day: int - pets: Animal Talkative
- Month: int - Owner: String
- Year: int + Speak():void
+Pet(Animal p,owner:String)
+ Date(d:int,m:int, y:int) +getPets ():Animal
+getMonth ():int +set Owner(n:String):void
Animal
- Kind: int
AnimalHospital - Name:String
-RecDate: Date
+ Animal (n:String,k:String)
-Type: Pet
+getName():String
+ AnimalHospital (Animal p,owner:String ,d:int,m:int, y:int)
+getRecDate ():Date
+ getType ():Pet
Cat Dog
المطلوب. Rec2 وRec1 ) واسند إليهاList( اسمهاAnimalHospital اعتبر إن لديك مصفوفة من-9
)5.3 point( 21 طباعة قائمة بإسماء الحيوان االليف في شهر
for(int i=0;i<2;i++)// Mark
if (List[i].getRecDate().getMonth()==12) // 1 Mark
System.out.printeln(“Name of Pet: ”+List[i]. getType(). getPets(). getName());//2 Mark