Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c. There is a has-a relationship between MyClass and YourClass. d. There is no r

ID: 3720690 • Letter: C

Question

c. There is a has-a relationship between MyClass and YourClass. d. There is no relation ship between MyClass and HerClass. ponse 8. (cast) (p. 611). Consider the classes: public class HerClass f private String name; public class YourClass extends HerClasst private String degree; public class HisClass extends YourClasst private String degree; public class Demo( public static void main(Stringl) arg)t Your Class peter new HisClass): //line 1 HisClass james new Her Class0: /line 2 HerClass john anew HerClassi: /line 3 HerClass kim F new YourClass(): /line 4 is not legal. b. line 2 d. line 4 a. Line 1 9. (collections Consider the classes: public class Student implements Comparable

Explanation / Answer

Ans)

b) line 2

________________

Reason:

HisClass james = new HerClass();

This is invalid because, Sub class reference cannot refer Super class object.

Here Sub class(HisClass) referenc ecannot refer to SuperClass Object(HerClass)

_______________Thank You