Question 8 Given the following declarations, public class Parent { ... } public
ID: 3846010 • Letter: Q
Question
Question 8
Given the following declarations,
public class Parent { ... }
public class Child extends Parent implements Wizard { ... }
public class Grandchild extends Child { ... }
Which of the following is NOT true?
Flag this Question
Question 9
In Java a class can inherit members from more than 1 super class.
Flag this Question
Question 10
Given the following definition:
public class Alpha implements Freezable {...}
And the following client code:
Freezable f = new Alpha();
Which is true?
Flag this Question
Question 11
Which of the following creates a new data type?
Child "Is-A" WizardExplanation / Answer
8) Parent "Is-A" Wizard is not true as it doesn't implement the interface Wizard. You cal also check this using "instanceof".
9) False. It is not possible for a class in java to extend from more than one class. Java doesn't support multiple inheritance to avoid confusion and ambiguity.
10) The variable f has static type Freezable and dynamic type Alpha. Why? As you can see from the declaration that f is declared at compile time only but is assigned the Alpha class during runtime i.e. dynamic binding.
11) I guess it should be All of the above because when you define a new interface or class you are defining a new reference data type. If you assign an object of that type, it will have the properties of that interface or class.
If you have further doubts, let me know in the comments !
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.