Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

305 mg of C6H12O6 in 55.2 mL of solution whats the molarity

Answered: 1 week ago

Question

How does an abstract word differ from a concrete word? [LO-4]

Answered: 1 week ago