Presentation is loading. Please wait.

Presentation is loading. Please wait.

Inheritance comp249. Question 1 What type of inheritance does Java have? a) single inheritance b)double inheritance c) multiple inheritance d)class inheritance.

Similar presentations


Presentation on theme: "Inheritance comp249. Question 1 What type of inheritance does Java have? a) single inheritance b)double inheritance c) multiple inheritance d)class inheritance."— Presentation transcript:

1 Inheritance comp249

2 Question 1 What type of inheritance does Java have? a) single inheritance b)double inheritance c) multiple inheritance d)class inheritance Answer: a

3 Question 2 What restriction is there on using the super reference in a constructor? a)It can only be used in the parent's constructor. b) Only one child class can use it. c) It must be used in the last statement of the constructor. d)It must be used in the first statement of the constructor. Answer: d

4 Question 3 A class Animal has a subclass Mammal. Which of the following is true: a)Because of single inheritance, Mammal can have no subclasses. b) Because of single inheritance, Mammal can have no other parent than Animal. c) Because of single inheritance, Animal can have only one subclass. d)Because of single inheritance, Mammal can have no siblings. e)Answer: b

5 Question 4 Does a subclass inherit both member variables and methods? a)No—only member variables are inherited. b)No—only methods are inherited. c)Yes—both are inherited. d)Yes—but only one or the other are inherited. Answer: c

6 Question 5 Which of the following is correct syntax for defining a new class Jolt based on the superclass SoftDrink? a)class Jolt isa SoftDrink { //} b)class Jolt implements SoftDrink { // c) class Jolt defines SoftDrink { //additional definitions go here } d) class Jolt extends SoftDrink { //additional definitions go here } Answer: d


Download ppt "Inheritance comp249. Question 1 What type of inheritance does Java have? a) single inheritance b)double inheritance c) multiple inheritance d)class inheritance."

Similar presentations


Ads by Google