Java and OOP

Java and OOP

Assessment

Quiz

Computers

University

Practice Problem

Hard

Created by

Tuned Work

Used 1+ times

FREE Resource

Student preview

quiz-placeholder

12 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the super() keyword in Java?

It refers to the current object

It is used to call a superclass constructor or method

It creates a superclass object

It returns the superclass type

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is true about Java inheritance?

A) A class can inherit from multiple classes

B) A subclass can access private members of its superclass

C) Inheritance helps avoid redundancy and promotes code reuse

D) Java supports multiple inheritance

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is polymorphism in OOP?

The ability to define methods with different signatures in the same class

The ability for a method in a subclass to override a method in its superclass

The ability to assign different objects to a reference variable of a superclass type

The ability to use the same method name in a class with different return types

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is an example of encapsulation in Java?

Declaring all data members as private and providing public getter and setter methods

Using the super keyword to call a superclass method

Declaring multiple classes in a single file

Overriding a method in the subclass

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In Java, what happens if you do not explicitly call a superclass constructor?

The default constructor of the superclass is called automatically.

The subclass constructor fails to compile.

No constructor is called, and the object is not created.

The JVM throws a runtime exception.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens if a subclass constructor does not explicitly call a superclass constructor in Java?

The subclass constructor will automatically call the superclass constructor

The program will throw an error

The subclass constructor must always call a superclass constructor explicitly

Java will call the this() constructor for the subclass

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main difference between method overloading and method overriding?

Overloading happens at runtime, while overriding happens at compile-time

Overloading involves different signatures, and overriding involves the same signature in both parent and subclass

Overloading is used for constructors, and overriding is used for methods

Overloading is when the parent method is hidden by the subclass method

Create a free account and access millions of resources

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?