wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

oop final

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

How many types of design patterns are there?

a)

3

b)

5

c)

8

d)

10

2.

What is the main benefit of using a design pattern?

a)

It reduces the total codebase

b)

It allows for the separation of responsibilities

c)

It ensures that the code is easier to understand and debug

d)

All of the above

3.

Which of the following is NOT a creational design pattern?

a)

Singleton Pattern

b)

Factory Pattern

c)

Bridge Pattern

d)

Prototype Pattern

4.

Which of the following is a behavioral design pattern?

a)

Observer Pattern

b)

Composite Pattern

c)

Flyweight Pattern

d)

Builder Pattern

5.

What is a Singleton design pattern?

a)

A design pattern that allows you to ensure that a class has only one instance

b)

A design pattern that lets you fit more objects into the available amount of RAM

c)

A design pattern that separates an object's specification from its implementation

d)

A design pattern that ensures that the class has multiple instances

6.

Which of the following best describes the Factory Pattern in design patterns?

a)

It is used to create duplicate objects while keeping performance in mind.

b)

It involves a single class that is responsible to join functionalities of independent or incompatible interfaces.

c)

It involves a single class that is responsible to join functionalities of independent or incompatible interfaces.

d)

It allows an object to be created without exposing the creation logic to the client and the created object is referred to using a common interface.

7.

What is the use of the Builder Pattern?

a)

It simplifies the creation of complex objects by breaking the creation process into steps.

b)

It allows an object to alter its behavior when its internal state changes.

c)

It ensures a class has only one instance and provides a global point of access to it.

d)

It helps in hiding the complexities of the system and provides an interface to the client.

8.

What is Template Design Pattern?

a)

It defines the skeleton of an algorithm in a method, deferring some steps to subclasses.

b)

It ensures that a class has only one instance and provides a global point of access to it.

c)

It encapsulates a request as an object, thereby allowing for the parameterization of clients with queues, requests, and operations.

d)

t provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation

9.

Which package is primarily used for JDBC classes and interfaces?

a)

java.sql

b)

java.db

c)

java.jdbc

d)

java.database

10.

Which interface handles the result of a query?

a)

QuerySet

b)

DbResult

c)

ResultSet

d)

QueryResult

11.

What is the purpose of Run-Time Type Identification (RTTI) in Java?

a)

To allow a program to generate types at runtime

b)

To enable a Java program to identify and access the type of an object at runtime

c)

To prevent type errors in a program at compile time

d)

To increase the runtime efficiency of a program

12.

What do Java Generics allow programmers to do?

a)

Create classes that are not type-safe.

b)

Specify, with a single method declaration, a set of related methods.

c)

Avoid the use of the instanceof operator.

d)

Increase the runtime overhead of a program.

13.

Which of the following best describes lambda expressions in Java?

a)

A feature that allows the creation of anonymous classes only.

b)

A way to implement interfaces with multiple abstract methods.

c)

An anonymous method that can be used to implement methods defined in a functional interface.

d)

A tool used exclusively for collection manipulation.

14.

What characterizes static methods in interfaces?

a)

They can be overridden by implementing classes.

b)

They do not require an instance of the interface to be invoked.

c)

They are implemented to provide default behavior for all implementing classes.

d)

They increase the runtime overhead due to dynamic binding.

15.

Which operator is used with RTTI to check if an object is an instance of a specific class?

a)

==

b)

.equals()

c)

instanceof

d)

getClass()

16.

Which method is used to obtain a reference to the Class object in Reflection?

a)

getClass()

b)

getType()

c)

newInstance()

d)

getMethod()

17.

Is design pattern a logical concept.

a)

True

b)

False

18.

How many abstract methods can a functional interface have?

a)

One

b)

Two

c)

As many as needed

d)

None

19.

How are lambda expressions compiled in Java?

a)

Into anonymous inner classes

b)

Into regular methods of the class where they are defined

c)

Using a special lambda compiler

d)

Into instances of functional interfaces

20.

What does the executeQuery() method of the Statement interface return?

a)

An integer

b)

A boolean

c)

ResultSet

d)

PreparedStatement

21.

Which type of polymorphism is achieved by method overriding?

a)

Compile-time Polymorphism

b)

Runtime Polymorphism

c)

Operator Polymorphism

d)

Class Polymorphism

22.

What is method overriding?

a)

Changing the value of a method's parameters in the subclass

b)

Defining a method in the subclass that is already defined in the parent class with a different implementation

c)

Increasing the visibility of a method in a subclass

d)

Reducing the visibility of a method in a subclass

23.

Polymorphism in object-oriented programming is the ability to treat objects of any subclass as if they were objects of the superclass.

a)

True

b)

False

24.

An abstract class in Java can be instantiated directly.

a)

True

b)

False

25.

Method Overloading is a type of Runtime Polymorphism.

a)

True

b)

False

26.

Polymorphism in Java is limited to the use of interfaces.

a)

True

b)

False

27.

Which blocks are used to handle exceptions in Java?

a)

if-else blocks

b)

try-catch blocks

c)

switch-case blocks

d)

for-while blocks

28.

What does JDBC stand for?

a)

Java Database Connectivity

b)

Java Data Connection Base

c)

Java Development Connection Bridge

d)

Java Direct Class Base

29.

Exception handling in Java is designed to handle runtime errors, allowing the program to continue executing.

a)

True

b)

False

30.

The finally block is executed only if no exceptions are thrown within the try block.

a)

True

b)

False

31.

A single method in Java can throw multiple types of exceptions.

a)

True

b)

False

32.

You must install the JDBC API explicitly to use it in your projects.

a)

True

b)

False

33.

What is the purpose of try-catch in Java?

a)

To handle compile-time errors

b)

To handle runtime exceptions

c)

To improve code performance

d)

To terminate the program

34.

Which method is used to execute an SQL query in JDBC?

a)

executeQuery()

b)

executeUpdate()

c)

execute()

d)

executeBatch()

35.

Which keyword is used to throw an exception explicitly in Java?

a)

Throw

b)

Catch

c)

Try

d)

Finally

36.

What distinguishes the Factory Method Design Pattern from other Creational Patterns?

a)

It allows classes to defer instantiation to subclasses.

b)

It ensures that a class has only one instance.

c)

It focuses on building complex objects step by step.

d)

It is primarily used for object cloning.

37.

Which of these is a valid lambda expression in Java?

a)

x, y -> x + y

b)

(x, y) -> x + y

c)

(x, y) => x + y

d)

(x + y)

38.

What does polymorphism mean in the context of object-oriented programming?

a)

The ability of different classes to respond to the same function call

b)

The process of converting a superclass type to a subclass type

c)

A programming technique that involves many forms of loops

d)

The method of creating multiple classes from a single class

39.

What is an abstract class in Java?

a)

A class that cannot be instantiated and is designed to be a superclass

b)

A class that can be instantiated and used directly

c)

A final class that cannot be extended

d)

A class without any methods

40.

What does upcasting refer to?

a)

Casting a subclass type to a superclass type

b)

Casting a superclass type to a subclass type

c)

Casting between unrelated classes

d)

Casting within the same class type