Answered step by step
Verified Expert Solution
Question
1 Approved Answer
9) [16 pts] Answer the following questions using the figure and the code below. e) [2 pts each] State the execution result (compile error, runtime
9) [16 pts] Answer the following questions using the figure and the code below. e) [2 pts each] State the execution result (compile error, runtime error - ClassCastException, or no problem for the following statements and explain the reason for the error cases. Each case is independent from each other. Suppose the method amethod is defined in the Class4. i) obj.aMethod(); d) [1 pt] Is obj2 instanceof Interface1? True False b) $[1 \mathrm{pt} ]$ Is obj3 instanceof Interface1? True False c) [1 pt] Is obj4 instanceof Interface3? True False a) [1 pt] Is obji instanceof Interface2? True False Class4 Interfacel obj1 = new Class(); Abstracti obj2 = new Class1(); Object obj3 = new class2(); Class3 obj4 = new Class4(); ii) Interface3 obj5 = obj2; iii) ((Class3)obj3). aMethod(); iv) $(Class 4) \operatorname{obj} 4) \cdot a Method ;$ f) [4 pts] Suppose that method "void $\mathrm{m} 20\{U} ;{ }^{\prime \prime} $ is in Abstract. Which classes have to implement it? CS.VS.922 - 9) [16 pts] Answer the following questions using the figure and the code below. e) [2 pts each] State the execution result (compile error, runtime error - ClassCastException, or no problem for the following statements and explain the reason for the error cases. Each case is independent from each other. Suppose the method amethod is defined in the Class4. i) obj.aMethod(); d) [1 pt] Is obj2 instanceof Interface1? True False b) $[1 \mathrm{pt} ]$ Is obj3 instanceof Interface1? True False c) [1 pt] Is obj4 instanceof Interface3? True False a) [1 pt] Is obji instanceof Interface2? True False Class4 Interfacel obj1 = new Class(); Abstracti obj2 = new Class1(); Object obj3 = new class2(); Class3 obj4 = new Class4(); ii) Interface3 obj5 = obj2; iii) ((Class3)obj3). aMethod(); iv) $(Class 4) \operatorname{obj} 4) \cdot a Method ;$ f) [4 pts] Suppose that method "void $\mathrm{m} 20\{U} ;{ }^{\prime \prime} $ is in Abstract. Which classes have to implement it? CS.VS.922
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started