wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Oops Quiz

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

What is the size of an int in Java?

a)

8 bits

b)

16 bits

c)

32 bits

d)

64 bits

2.

Which of these is not a Java keyword?

a)

Static

b)

Void

c)

Integer

d)

new

3.

Which method is the entry point for any Java program?

a)

start()

b)

run()

c)

init()

d)

main()

4.

What is the output of System.out.println(5 + "5");?

a)

10

b)

55

c)

Compilation error

d)

Runtime error

5.

Which of the following is the correct way to create an object in Java?

a)

MyClass obj = MyClass();

b)

MyClass obj = new MyClass();

c)

obj = new MyClass();

d)

MyClass obj();

6.

What will System.out.println(10 / 4); print?

a)

2.5

b)

2

c)

2.0

d)

Compilation error

7.

Which of these allows you to reuse code in Java?

a)

Class

b)

Object

c)

Inheritance

d)

Interface

8.

What is the purpose of the final keyword?

a)

To define a constant

b)

To create a new object

c)

To allow modifications

d)

To indicate recursion

9.

Which feature of OOPS derives new classes from existing classes?

a)

Encapsulation

b)

Polymorphism

c)

Inheritance

d)

Abstraction

10.

Who invented JAVA programming?

a)

Guido van Rossum

b)

James Gosling

c)

Dennis Ritchie

d)

Bjarne Stroustrup

11.

In java, objects are created using this operator

(a)  

12.

Select the correct syntax

a)

public static void main(String args[])

b)

public static void main(string args[])

c)

public static void main()

d)

public void main(String args[])

13.

Java is a case sensitive Language.

a)

True

b)

False

14.
. Java Source Code is compiled into ______________.
a)
.Obj
b)
Source Code
c)
Byte Code
d)
.Exe
15.

Which of the following tells that same method name with different parameters

a)

Methodoverloading

b)

Override

c)

Method overiding

d)

Overloaded

16.

An_____is a collection of same datatype of elements

a)

Object

b)

Array

c)

Class

d)

Framework

17.

What is the result of combining data and the methods that operate on that data into a single unit?

a)

Inheritance

b)

Polymorphism

c)

Encapsulation

d)

Abstraction

18.

Which principle ensures that implementation details are hidden?

a)

Polymorphism

b)

Abstraction

c)

Inheritance

d)

Encapsulation

19.

Which keyword prevents a method from being overridden?

a)

static

b)

final

c)

abstract

d)

private

20.

In Java, a class can implement:

a)

Only one interface

b)

Multiple interfaces

c)

No interface

d)

Only abstract classes

21.

What is the advantage of inheritance?

a)

Less memory use

b)

Improved security

c)

Code reuse

d)

Better compilation

22.

Which of the following best defines encapsulation?

a)

Writing one function inside another

b)

Keeping data and methods in the same class

c)

Making all variables public

d)

Using inheritance

23.

Polymorphism allows:

a)

Objects to take many forms

b)

Functions to hide data

c)

Only one method

d)

Variables to be static

24.

Which of the following is NOT a type of inheritance in OOP?

a)

Single

b)

Multiple

c)

Multilevel

d)

Super

25.

Which access modifier provides the highest level of encapsulation?

a)

public

b)

private

c)

protected

d)

default

26.

What is method overloading an example of?

a)

Encapsulation

b)

Compile-time polymorphism

c)

Abstraction

d)

Inheritance

27.

What is the process of hiding internal details and showing functionality called?

a)

Encapsulation

b)

Inheritance

c)

Abstraction

d)

Polymorphism

28.

Which pillar of OOP is achieved using abstract classes and interfaces?

a)

Encapsulation

b)

Inheritance

c)

Polymorphism

d)

Abstraction

29.

Which keyword is used to inherit a class in Java?

a)

implements

b)

inherits

c)

extends

d)

includes

30.

What does encapsulation help achieve?

a)

Code duplication

b)

Data hiding

c)

Global variables

d)

Slower performance

31.

Which of the following is NOT a pillar of OOP?

a)

Encapsulation

b)

Abstraction

c)

Compilation

d)

Polymorphism

32.

Which of these keywords are used to define an abstract class?

a)

Abstract

b)

abstract

c)

abstract class

d)

abst

33.

Predict the output of following program. Note that foo() is public in base and private in derived.

class Base { public void foo() { System.out.println("Base"); }} class Derived extends Base { private void foo() { System.out.println("Derived"); } } public class Main { public static void main(String args[]) { Base b = new Derived(); b.foo(); }}

a)

Base

b)

Derived

c)

Compile Time Error

d)

Run time error

34.

What is the output of the following code: int[] arr = new int[5]; System.out.println(arr[5]);?

a)

No output

b)

ArrayIndexOutOfBoundsException

c)

0

d)

5

35.

Which class is the base class for all exceptions in Java?

a)

Error

b)

Throwable

c)

Exception

d)

RuntimeException

36.

abstraction hides the

a)

class

b)

complexity

37.

Which component is used to compile, debug and execute the java programs?

a)

JRE

b)

JVM

c)

JIT

d)

JDK

38.

Which method can used to find the length of string?

a)

stringlength()

b)

length()

c)

getLength()

d)

getSize()

39.

Which of the following is not an object-oriented programming language?

a)

Objective C

b)

C++

c)

JAVA

d)

Pascal

40.

Which feature JAVA does not support?

a)

Polymorphism

b)

Inheritance

c)

Pointer

d)

Portable