Search Header Logo

Unit 9 Quiz 1 Review

Authored by Michael Courtright

Computers

9th - 12th Grade

Used 1+ times

Unit 9 Quiz 1 Review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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);

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?