Answered step by step
Verified Expert Solution
Question
1 Approved Answer
21. (15 marks] Suppose that Fruit, Apple, Orange, Golden Delicious, and McIntosh are defined in the following inheritance hierarchy: Fruit Apple Orange + makeAppleCider():void +
21. (15 marks] Suppose that Fruit, Apple, Orange, Golden Delicious, and McIntosh are defined in the following inheritance hierarchy: Fruit Apple Orange + makeAppleCider():void + makeOrange Juice(): void Golden Delicious Mcintosh And assume that the following code is given: Fruit fruit = new Golden Delicious(); Orange orange = new Orange(); Answer the following questions, and explain your answer. a. Is fruit instanceof Fruit? b. Is fruit instanceof Orange? C. is fruit instanceof Apple? d. Is fruit instanceof Golden Delicious? e. Is fruit instanceof McIntosh? f. Is orange instanceof Orange? g. Is orange instanceof Fruit? h. Is orange instanceof Apple? i. Can fruit invoke makeAppleCider method? j. Can orange invoke makeAppleCider method? k. Can fruit invoke makeOrange Juice method? I. Can orange invoke makeOrange Juice method? m. Is the statement Orange p = new Apple () legal? n. Is the statement McIntosh p = new Apple () legal? o. is the statement Apple p = new McIntosh() legal
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