Unit 9 Quiz 1 Review

Unit 9 Quiz 1 Review

9th - 12th Grade

8 Qs

quiz-placeholder

Similar activities

Java Inheritance

Java Inheritance

9th - 12th Grade

5 Qs

Inheritance

Inheritance

10th Grade

10 Qs

Java

Java

11th Grade

10 Qs

Creative tech summative exam

Creative tech summative exam

9th - 12th Grade

10 Qs

Python Generators

Python Generators

10th Grade - University

10 Qs

OOPS in Python

OOPS in Python

12th Grade

10 Qs

Penilaian Harian-1 Pemodelan Berorientasi Objek

Penilaian Harian-1 Pemodelan Berorientasi Objek

12th Grade

10 Qs

Inheritance

Inheritance

12th Grade

7 Qs

Unit 9 Quiz 1 Review

Unit 9 Quiz 1 Review

Assessment

Quiz

Computers

9th - 12th Grade

Hard

Created by

Michael Courtright

Used 1+ times

FREE Resource

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Consider the following statements about Java hierarchies.

I. A class that is derived from another class is a subclass (also called a derived class, an extended class, or a child class). The class from which the subclass is derived is a superclass (also called a base class or a parent class). 

II. Except for Object, which has no superclass, every class has one and only one direct superclass. In the absence of any other explicit superclass, every class is implicitly a subclass of Object.

III. Classes can be derived from classes that are derived from classes that are derived from classes, and so on, and they are all ultimately derived from the topmost class, Object.

Which of these statements is/are true?

I only

II only

III only

I and II

I, II, and III

Answer explanation

A class derived from another class is a subclass, and the class from which the subclass is derived is a superclass.

Derived classes can be derived from other derived classes. Every class has one and only one direct superclass.

2.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Consider the following Java hierarchy, in which A, B, and C are class objects.

Which of the following shows the correct use of the extends keyword to create the class hierarchy depicted above?

public class A { }

public class B extends A { }

public class C extends A { }

private class A { }

public class B extends A { }

public class C extends A { }

public class A { }

public class B { }

public class C { }

public class A { }

public class A extends B { }

public class A extends C { }

public class A extends B C { }

public class B { }

public class C { }

3.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

public class A {}

public class B extends A { }

public class C extends A { }

public class D extends B { }

public class E extends A { }

Which type of Java inheritance is depicted by the above code segment?

multilevel inheritance

single inheritance

hybrid inheritance

hierarchical inheritance

class inheritance

4.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Consider the following Java hierarchy, in which A, B, C, and D are class objects.

I only

II only

III only

I and II

I, II, and III

5.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Which of the following statements about the Is-A and Has-A relationships is/are correct?

I. Is-A relationship: public class MountainBike extends Bike {}

II. Has-A relationship: class House { Kitchen kitchen = new Kitchen(); }

III. A Is-A relationship is a static (compile time) binding. 

A Has-A relationship is dynamic (run time) binding.

I only

II only

III only

I and II

I, II, and III

6.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

public class Superclass { }

public class Subclass extends Superclass {         

public static void main(String[] args) {         

Subclass s = new Subclass();     }

}

How does Java handle the above situation, in which there is no explicit constructor defined for the subclass or its superclass?

If the subclass has no constructor, Java will not use any constructor from the superclass.

If a subclass does not have an explicit constructor, the compiler uses the default constructor from its superclass.

A subclass must have an explicit constructor.

Either the superclass or the subclass must have an explicit constructor.

A superclass must have an explicit constructor.

7.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

public class Superclass {     

public String classTitle;     }

public class Subclass extends Superclass {         

public static void main(String[] args) {         

Subclass subC = new Subclass();        

 /* Missing statement 1 /  / Missing statement 2 */     

} }

Which of the following shows the correct replacements for "Missing statement 1" and "Missing statement 2" if the code segment displays "Subclass" as an output?

subC.classTitle = "Subclass";

System.out.println(subC.classTitle);

classTitle = "Subclass";

System.out.println(classTitle);

superC.classTitle = "Subclass";

System.out.println(superC.classTitle);

subC.setclassTitle("Subclass");

System.out.println(subC.classTitle);

subC.classTitle("Subclass");

System.out.println(subC.classTitle);

8.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

public class Superclass {     

private String classTitle;     }

public class Subclass { }

What is the proper process for an instance of Subclass named subC to access the String variable classTitle?

Use the access methods for classTitle provided by the superclass.

subC.setclassTitle("Subclass");

subC.classTitle = "Subclass";

subC.classTitle("Subclass");

classTitle = "Subclass";