wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

OOP Final Exam

Total questions: 100

Worksheet time: 1hrs 15mins

Name
Class
Date
1.
What does OOP stand for in Java?
a)
Object-Oriented Programming
b)
Object-Oriented Process
c)
Operator-Oriented Programming
d)
Object-Operation Program
2.
Which paradigm is Java primarily known for?
a)
Object-Oriented
b)
Functional
c)
Logic
d)
Assembly
3.
Which is a benefit of OOP?
a)
Modularity and reusability
b)
Slower runtime by design
c)
No real-world mapping
d)
No team collaboration support
4.
Complete the print statement: System.out.________("Hello, World!");
a)
println
b)
printline
c)
write
d)
printf
5.
Complete the main method header: public static void ______(String[] args) { }
a)
start
b)
main
c)
run
d)
begin
6.
What is the entry point method of a Java application?
a)
public static void run(String[] args)
b)
public static void main(String[] args)
c)
public static void start(String[] args)
d)
public void main()
7.
Which statement prints a line in Java?
a)
System.print("Hello");
b)
System.out.write("Hello");
c)
System.out.println("Hello");
d)
Console.log("Hello");
8.
Java’s slogan 'Write Once, Run Anywhere' refers to:
a)
Bytecode portability via JVM
b)
Only desktop apps
c)
Only Windows compatibility
d)
Auto-translating to all languages
9.
Complete the class declaration: public ______ HelloWorld { }
a)
void
b)
class
c)
main
d)
static
10.
Declare an int variable count with value 0: int ______ = 0;
a)
count
b)
counts
c)
0count
d)
Count
11.
Which of the following is true about Java variables?
a)
Java is dynamically typed
b)
Java requires a declared type
c)
Variables cannot be updated
d)
Variable names must start with a digit
12.
Which of the following is a primitive type in Java?
a)
String
b)
int
c)
ArrayList
d)
Scanner
13.
Which is a non-primitive (reference) type?
a)
int
b)
double
c)
String
d)
boolean
14.
Declare a double price with 19.99: double price ______ 19.99;
a)
=
b)
==
c)
equals
d)
<-
15.
Declare a String name as "Juan": String name = ______Juan";
a)
'
b)
"
c)
`
d)
\"
16.
Which operator checks equality in Java?
a)
=
b)
==
c)
:=
d)
equals
17.
Which operator represents logical AND?
a)
&&
b)
||
c)
!
d)
&=
18.
Which control structure repeats a block while a condition is true (checked before executing)?
a)
do-while loop
b)
for-each loop
c)
while loop
d)
switch
19.
Declare a boolean flag true: boolean isPassed = ______;
a)
TRUE
b)
True
c)
true
d)
yes
20.
Char literal for letter A: char grade = ______;
a)
"A"
b)
'A'
c)
A
d)
`A`
21.
Which control structure is best when the number of iterations is known?
a)
while
b)
do-while
c)
for
d)
if-else
22.
Which keyword starts a conditional branch?
a)
for
b)
if
c)
switch
d)
case
23.
Which is a common mistake in Java?
a)
Using == for comparison
b)
Case sensitivity
c)
No semicolons required
d)
Class name can differ from filename
24.
Equality check in if: if (x ______ y) { }
a)
=
b)
==
c)
:=
d)
equals
25.
Logical AND in a condition: if (a > 0 ______ b > 0) { }
a)
||
b)
&&
c)
&=
d)
!
26.
What is a method in Java?
a)
A named block of code that performs a task
b)
A variable container
c)
A file header comment
d)
An external library
27.
Why use methods?
a)
To duplicate code often
b)
To make code less readable
c)
To organize and reuse logic
d)
To avoid parameters
28.
Which keyword indicates a method returns no value?
a)
return
b)
void
c)
null
d)
none
29.
Modulus operator example: int r = a ______ b;
a)
%
b)
/
c)
*
d)
//
30.
Declare a void method greet: public ______ greet() { }
a)
void
b)
int
c)
return
d)
main
31.
Which part of a method holds the statements?
a)
Method header
b)
Method body
c)
Method return
d)
Method signature
32.
What is passed into a method to provide input?
a)
Parameters
b)
Arguments
c)
Fields
d)
Statements
33.
What is returned by a method with return type int?
a)
A boolean value
b)
No value
c)
An integer value
d)
A method name
34.
Call greet() from object obj: ______.greet();
a)
obj
b)
this
c)
class
d)
greet
35.
Method with return: public int add(int a,int b){ ______ a + b; }
a)
return
b)
yield
c)
break
d)
continue
36.
Method overloading means:
a)
A subclass replaces a parent method
b)
Same name, different parameters
c)
Multiple classes share a method
d)
A method calling itself
37.
Which is valid overloading?
a)
void print() and void print()
b)
int add(int,int) and double add(double,double)
c)
void draw(int) and void draw(int)
d)
void go() and go void()
38.
A class in Java is:
a)
A blueprint for objects
b)
A running object
c)
An IDE feature
d)
A package
39.
Overloaded method header: void print(String s) and void print(________)
a)
int a
b)
String s
c)
String... s
d)
int, int
40.
Instantiate Car: Car c = ______ Car();
a)
create
b)
new
c)
make
d)
spawn
41.
An object is:
a)
A template for a class
b)
An instance created from a class
c)
A directory
d)
A JVM
42.
Fields in a class are:
a)
Methods
b)
Variables that store object data
c)
Packages
d)
Interfaces
43.
Methods in a class are:
a)
Functions describing behavior
b)
Variables storing data
c)
Files
d)
Annotations
44.
Constructor with args: Car c = new Car("Hilux", ______);
a)
2025
b)
"2025"
c)
'2025'
d)
year:2025
45.
Field declaration: private int year; -> Access modifier is ______
a)
private
b)
public
c)
protected
d)
default
46.
A constructor is:
a)
A method called when creating objects
b)
A method to destroy objects
c)
A static field
d)
A package
47.
What must match the class name?
a)
Constructor name
b)
Any method name
c)
Variable name
d)
Package name
48.
Which statement creates a new object?
a)
Car c;
b)
new Car;
c)
Car c = new Car();
d)
Car();
49.
Method in class: public ______ honk(){ System.out.println("Beep!"); }
a)
void
b)
int
c)
String
d)
static
50.
Constructor name equals class: class Car { ______ Car() { } }
a)
public
b)
void
c)
int
d)
static
51.
Encapsulation primarily means:
a)
Bundling data and methods within a class
b)
Using many global variables
c)
Separating data from methods
d)
Storing data in public fields
52.
Which access modifier restricts access to the same class only?
a)
protected
b)
default (package-private)
c)
private
d)
public
53.
Which access modifier is visible to everyone?
a)
private
b)
public
c)
protected
d)
default
54.
Getter header for name: public String ______(){ return name; }
a)
getName
b)
setName
c)
Name
d)
getterName
55.
Setter header for gwa: public void ______(double gwa){ this.gwa = gwa; }
a)
getGwa
b)
setGwa
c)
gwa
d)
setGWA
56.
Which access modifier allows same package + subclasses?
a)
default
b)
public
c)
private
d)
protected
57.
Best practice for fields in encapsulation is:
a)
public fields, private methods
b)
private fields, public methods
c)
all public
d)
all private
58.
What are 'getters'?
a)
Methods that return field values
b)
Methods that set field values
c)
Constructors
d)
Static fields
59.
Use this in setter: this.____ = gwa;
a)
GWA
b)
gwa
c)
setGwa
d)
gWas
60.
Private field declaration: ______ String model;
a)
public
b)
private
c)
protected
d)
default
61.
What are 'setters'?
a)
Methods that update fields (with validation)
b)
Methods that delete objects
c)
Methods that return fields
d)
Interfaces
62.
The 'this' keyword is used to:
a)
Refer to the current object’s members
b)
Import packages
c)
Create a new object
d)
Call static methods
63.
A setter should:
a)
Ignore invalid input
b)
Optionally validate before assignment
c)
Always assign without checks
d)
Set other unrelated fields
64.
Expose method publicly: ______ void drive(){ }
a)
private
b)
default
c)
public
d)
protected
65.
Subclass declaration: class Dog ______ Animal { }
a)
implements
b)
extends
c)
inherits
d)
uses
66.
What does 'static' on a field imply?
a)
One copy shared by all objects
b)
Many copies per object
c)
Field cannot be accessed
d)
Field is transient
67.
Inheritance in Java allows a class to:
a)
Acquire properties/behaviors from a parent class
b)
Contain unrelated functions only
c)
Be the same as interfaces
d)
Hide all methods
68.
Keyword used for class inheritance:
a)
implements
b)
extends
c)
inherits
d)
superclass
69.
Call parent constructor: super(brand, ______);
a)
price
b)
this.price
c)
new price
d)
super.price
70.
Override annotation: @________ public void sound(){ }
a)
Overload
b)
Override
c)
Implement
d)
Extend
71.
A subclass is also called a:
a)
Superclass
b)
Child class
c)
Interface
d)
Module
72.
In Java, a class can extend:
a)
Multiple classes
b)
Exactly one class
c)
Zero classes only
d)
Unlimited classes simultaneously
73.
What cannot be inherited directly by a subclass?
a)
Methods
b)
Fields
c)
Constructors
d)
Public members
74.
Override signature must match ______ and return type.
a)
name only
b)
parameters
c)
package
d)
constructor
75.
Polymorphic call: Animal a = new Dog(); a.________();
a)
sleep
b)
sound
c)
bark
d)
move
76.
What does 'super' commonly do?
a)
Access parent members / call parent constructor
b)
Create a subclass
c)
Import a package
d)
Mark a static member
77.
Method overriding requires:
a)
Same name, parameters, return type
b)
Different parameters
c)
Different return type
d)
Adding static
78.
The @Override annotation is used to:
a)
Overload a method
b)
Indicate a method overrides a parent method
c)
Create a constructor
d)
Mark static methods
79.
Implement interface Shape: class Circle ______ Shape { }
a)
extends
b)
implements
c)
inherit
d)
uses
80.
Interface method has ______ only.
a)
method bodies
b)
method signatures
c)
constructors
d)
fields only
81.
Abstraction focuses on:
a)
How an object does it
b)
Detailed implementation
c)
What an object does
d)
Memory management only
82.
Abstract classes can:
a)
Be instantiated directly
b)
Contain abstract and concrete methods
c)
Contain only interfaces
d)
Replace interfaces
83.
Polymorphism enables:
a)
One name, many behaviors
b)
One behavior, many names
c)
No method reuse
d)
Static-only methods
84.
Variable of interface type: Shape s = new ______();
a)
Shape
b)
Circle
c)
Object
d)
Shape()
85.
Multiple interfaces: class Frog implements Swimmable, ______ { }
a)
Runnable
b)
Extendable
c)
IterableClass
d)
Abstractable
86.
Compile-time polymorphism refers to:
a)
Overriding
b)
Overloading
c)
Dynamic binding
d)
Reflection
87.
Run-time polymorphism refers to:
a)
Overloading
b)
Overriding
c)
Preprocessing
d)
Inlining
88.
Interfaces in Java define:
a)
Method bodies only
b)
Method signatures (contracts)
c)
Only fields
d)
Constructors
89.
Interface method implementation must be ______.
a)
private
b)
abstract
c)
public
d)
package-private
90.
for loop header: for (int i = 0; i < 5; ______) { }
a)
i++
b)
++i;
c)
i+=;
d)
i--
91.
A class implements an interface using:
a)
extends
b)
uses
c)
implements
d)
requires
92.
Interfaces support:
a)
Multiple inheritance of type
b)
Multiple inheritance of implementation
c)
No inheritance
d)
Only abstract classes
93.
Which is valid interface usage?
a)
class Circle extends Shape
b)
class Circle implements Shape
c)
interface Circle implements Shape
d)
class Circle imports Shape
94.
while loop increment: while(i<5){ System.out.println(i); ______; }
a)
i++
b)
++i;
c)
i += 1;
d)
All of these
95.
do-while close: } ______ (i < 5);
a)
while
b)
for
c)
if
d)
repeat
96.
Why use interfaces?
a)
To couple code tightly
b)
To vary behavior behind a common type
c)
To prevent polymorphism
d)
To store data only
97.
Which declaration is valid?
a)
int 2x = 2;
b)
int x2 = 2;
c)
int-x = 2;
d)
int x- = 2;
98.
Which literal represents a char?
a)
'A'
b)
"A"
c)
A
d)
`A`
99.
If-else example: if(x>=85){...} ______ { System.out.println("NOT Qualified"); }
a)
else
b)
otherwise
c)
elseif
d)
case
100.
Concatenation: String s = "Hello" + ______ + "!";
a)
" "
b)
' '
c)
space
d)
" "