wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

ISB16003 OOP - Final Revision (1-4)

Total questions: 102

Worksheet time: 59mins

Name
Class
Date
1.

REVISION 1

What does CPU stand for in computing?

a)

Central Processing Unit

b)

Computer Personal Unit

c)

Control Programming Unit

d)

Central Programming Unit

2.

Which of the following is a high-level programming language?

a)

Assembly

b)

Java

c)

Binary

d)

Machine Code

3.

What is the correct file extension for a Java source file?

a)

.jav

b)

.java

c)

.class

d)

.jar

4.

Which component is responsible for translating Java code to bytecode?

a)

JVM

b)

Compiler

c)

Assembler

d)

IDE

5.

Which of the following is NOT a primitive data type in Java?

a)

int

b)

String

c)

boolean

d)

double

6.

In Java, what keyword is used to define a class?

a)

define

b)

struct

c)

class

d)

object

7.

Which of the following is used for single-line comments in Java?

a)

/* comment */

b)

// comment

c)

# comment

d)

<!--comment-->

8.

Which method serves as the entry point for a Java program?

a)

public class main()

b)

static void Main()

c)

public static void main(String[] args)

d)

main()

9.

Which statement correctly declares an integer variable in Java?

a)

int x = "10";

b)

int x = 10;

c)

integer x = 10;

d)

num x = 10;

10.

What will the expression 5 / 2 return in Java?

a)

2.5

b)

3

c)

2

d)

2.0

11.

What does the System.out.println() function do?

a)

Reads user input

b)

Declares a variable

c)

Prints output to the console

d)

Terminates the program

12.

Which of these is a valid identifier in Java?

a)

1stValue

b)

first-value

c)

firstValue

d)

class

13.

Which data type should be used to store true/false values?

a)

char

b)

int

c)

bool

d)

boolean

14.

What is the purpose of the import statement in Java?

a)

To define new classes

b)

To include standard libraries

c)

To start execution

d)

To declare variables

15.

What is the result of 10 % 3 in Java?

a)

3

b)

1

c)

0

d)

2

16.

Which of the following best describes the role of the Java Virtual Machine (JVM)?

a)

Converts bytecode to machine code

b)

Compiles Java to binary

c)

Executes only .jar files

d)

Manages file input/output

17.

Which statement about Java memory management is true?

a)

Java uses manual memory allocation

b)

The programmer must delete objects

c)

Java uses automatic garbage collection

d)

Memory is managed using pointers

18.

Given: int x = 5; x += x++ + ++x;, what is the final value of x?

a)

11

b)

16

c)

17

d)

12

19.

Which of the following is not true about Java bytecode?

a)

It's platform-independent

b)

It runs directly on hardware

c)

It's interpreted by the JVM

d)

It's the compiled version of Java source code

20.

What will the following code output?

int a = 5, b = 2;

System.out.println(a++ * ++b);

a)

10

b)

12

c)

15

d)

14

21-25.

Case Study: E-Learning Assignment Submission System (10 marks)

Scenario:

An E-Learning platform manages assignments submitted by students.

• A base class Assignment contains assignmentId, title, and submissionDate.

• Subclasses include EssayAssignment and CodingAssignment.

• Each assignment type has its own grading logic using a method gradeAssignment().

• Lecturers grade assignments through a list of Assignment objects.

• Assignment data must not be modified after submission.

• Late submission rules differ between assignment types.

21.

1. Different grading logic in each subclass is an example of:

a)

A. Abstraction

b)

B. Method Overloading

c)

C. Method Overriding

d)

D. Encapsulation

22.

2. To ensure all assignment types implement gradeAssignment(), the method should be declared as:

a)

A. final

b)

B. static

c)

C. abstract

d)

D. private

23.

3. Preventing modification of assignmentId after object creation can be achieved using:

a)

A. static

b)

B. final

c)

C. protected

d)

D. volatile

24.

4. Processing different assignment types using a single Assignment reference demonstrates:

a)

A. Inheritance

b)

B. Encapsulation

c)

C. Polymorphism

d)

D. Aggregation

25.

5. Late submission rules differ per assignment type. This design supports:

a)

A. Single Responsibility Principle

b)

B. Class-Specific Behavior

c)

C. Interface Segregation

d)

D. Data Hiding

26.

REVISION 2

Which of the following modifiers limits access to within the class only?

a)

public

b)

protected

c)

default

d)

private

27.

Encapsulation is implemented in Java by:

a)

Declaring attributes as public

b)

Declaring attributes as private and providing getters/setters

c)

Using abstract classes only

d)

Using interfaces

28.

Which of these is not an access modifier in Java?

a)

protected

b)

default

c)

private

d)

internal

29.

In UML, an abstract class name is written in:

a)

Bold

b)

Italics

c)

Underline

d)

Uppercase

30.

In Java, if no access modifier is specified, the default level is:

a)

public

b)

private

c)

protected

d)

package-private (default)

31.

Which keyword is used to inherit a class in Java?

a)

inherit

b)

derive

c)

extends

d)

implements

32.

A subclass can access which members of its superclass?

a)

private only

b)

protected and public

c)

default only

d)

all members including private

33.

Which of the following can be overridden?

a)

final methods

b)

private methods

c)

static methods

d)

public instance methods

34.

Which of these best describes inheritance?

a)

A method hiding mechanism

b)

A way to overload constructors

c)

A way to create multiple constructors

d)

A mechanism to derive new classes from existing ones

35.

The keyword super is used for:

a)

Accessing child class attributes

b)

Instantiating superclass

c)

Calling superclass constructor or method

d)

Referring to current object

36.

Which of the following is an example of dynamic binding?

a)

Method overloading

b)

Method overriding

c)

Static methods

d)

Constructors

37.

What is printed? class A { void show() { System.out.println("A"); } } class B extends A { void show() { System.out.println("B"); } } public class Test { public static void main(String[] args) { A obj = new B(); obj.show(); } }

a)

A

b)

B

c)

Compile-time error

d)

Runtime error

38.

What is method overloading?

a)

Changing method name in subclass

b)

Using same method name with different parameters in same class

c)

Overriding a method with new return type

d)

Hiding methods in subclass

39.

Which of the following is resolved at compile-time?

a)

Method Overriding

b)

Dynamic Method Dispatch

c)

Method Overloading

d)

Abstract method call

40.

Which of the following represents polymorphism?

a)

One interface, many implementations

b)

Static variable

c)

Final class

d)

Protected methods

41.

Static methods can access:

a)

Only static variables

b)

Both static and instance variables

c)

Only instance variables

d)

Non-static methods

42.

Final variables:

a)

Can be modified in subclass

b)

Can be initialized once only

c)

Are always static

d)

Cannot be used in loops

43.

Which is true about static methods?

a)

Can call instance methods

b)

Can use "this"

c)

Can be overridden

d)

Belong to the class

44.

Abstract methods:

a)

Must be static

b)

Must have a body

c)

Cannot exist in a non-abstract class

d)

Can be private

45.

A class that contains at least one abstract method must be:

a)

Static

b)

Final

c)

Public

d)

Abstract

46.

Which is true about Java interfaces?

a)

Can contain constructors

b)

Can contain method implementations

c)

Can contain only abstract methods and constants

d)

Cannot be implemented by classes

47.

A class can implement:

a)

One interface only

b)

Multiple classes

c)

Multiple interfaces

d)

One class and one interface only

48.

Which line is correct for interface implementation?

a)

class A extends B, implements C

b)

class A implements B, C

c)

interface A extends class B

d)

class A implements interface B

49.

What relationship does "implements" indicate in Java?

a)

is-a

b)

has-a

c)

is-a-kind-of

d)

uses-a

50.

Which of the following simulates multiple inheritance?

a)

Abstract classes

b)

Method overloading

c)

Interfaces

d)

Static methods

51-55.

Case Study: Online Banking Account Management System (10 marks)

Scenario: An Online Banking System manages different types of bank accounts.

• There is a base class BankAccount with attributes accountNumber, holderName, and balance.

• Subclasses include SavingsAccount and CurrentAccount.

• SavingsAccount applies interest, while CurrentAccount allows overdraft up to a limit.

• Each account type implements a method calculateMonthlyCharges().

• The system processes a list of BankAccount objects to calculate charges.

• Account details must be protected from direct modification.

51.

1. Implementing calculateMonthlyCharges() differently in SavingsAccount and CurrentAccount demonstrates:

a)

A. Encapsulation

b)

B. Method Overriding

c)

C. Composition

d)

D. Aggregation

52.

2. To prevent direct access to the balance attribute, it should be declared as:

a)

A. public

b)

B. protected

c)

C. private

d)

D. static

53.

3. Storing different account types in a single list of BankAccount objects relies on:

a)

A. Inheritance

b)

B. Encapsulation

c)

C. Polymorphism

d)

D. Abstraction

54.

4. If BankAccount should not be instantiated directly, how should it be defined?

a)

A. final class

b)

B. interface

c)

C. abstract class

d)

D. static class

55.

5. The overdraftLimit attribute exists only in CurrentAccount. This is an example of:

a)

A. Data Hiding

b)

B. Class-Specific Behavior

c)

C. Method Overloading

d)

D. Multiple Inheritance

56.

REVISION 3

Which keyword is used to implement encapsulation?

a)

public

b)

protected

c)

private

d)

static

57.

What is true about a static variable?

a)

It belongs to each object separately

b)

It is reinitialized for every new object

c)

It is shared across all instances

d)

It can only be used in interfaces

58.

Which of the following can access protected members?

a)

Any class

b)

Same package and subclasses

c)

Only the defining class

d)

Subclasses in different packages only

59.

A method defined as final:

a)

Can be overridden

b)

Cannot be inherited

c)

Cannot be overridden

d)

Must be abstract

60.

What does the super() keyword do in a subclass constructor?

a)

Calls the same class constructor

b)

Calls an interface method

c)

Calls superclass constructor

d)

Access private members of parent class

61.

Which of the following is true about abstract classes?

a)

Can be instantiated

b)

Can have abstract and concrete methods

c)

Must only contain abstract methods

d)

Must implement an interface

62.

What is the purpose of an interface in Java?

a)

To create constants

b)

To enforce multiple inheritance behavior

c)

To hold only data

d)

To create a final class

63.

Which of the following is true for static methods?

a)

They can use instance variables

b)

They can override non-static methods

c)

They can only access static members

d)

They must return void

64.

What keyword is used to prevent class inheritance?

a)

static

b)

final

c)

abstract

d)

protected

65.

What is the correct access level for members accessible in the same package only?

a)

private

b)

protected

c)

default

d)

public

66.

Which feature allows method calls to decide at runtime?

a)

Static binding

b)

Method overloading

c)

Method overriding

d)

Constructor chaining

67.

What happens if a subclass does not implement all abstract methods?

a)

It will compile

b)

It must be declared abstract

c)

It can override them later

d)

It inherits them by default

68.

How many interfaces can a class implement?

a)

Only one

b)

Two

c)

Multiple

d)

None

69.

Which keyword allows access to superclass methods/constructors?

a)

base

b)

parent

c)

super

d)

this

70.

What type of inheritance is not allowed in Java?

a)

Multilevel

b)

Hierarchical

c)

Multiple (with classes)

d)

Single

71.

Which method is used to convert an object into a string representation?

a)

convertToString()

b)

toString()

c)

stringFormat()

d)

getString()

72.

What is a UML class diagram used for?

a)

Testing a program

b)

Running a program

c)

Describing system structure

d)

Debugging

73.

Which polymorphism is applied when method signature is same in parent and child?

a)

Overloading

b)

Early binding

c)

Overriding

d)

Static binding

74.

What is the use of "this" keyword?

a)

Refer to a static method

b)

Refer to the current object

c)

Refer to a superclass

d)

Refer to global variable

75.

Which one is true about interface members?

a)

Can be private

b)

Can have implementation

c)

Must be abstract or static final

d)

Can have constructors

76.

What will be the output?

public class Circle {

static int numberOfObjects = 0;

public Circle() {numberOfObjects++;}

public static int getCount() {return numberOfObjects;}

public static void main(String[] args) {

Circle c1 = new Circle();

Circle c2 = new Circle();

System.out.println(Circle.getCount());

}

}

a)

1

b)

2

c)

0

d)

Error

77.

Which of the following declarations is correct for an abstract method?

a)

public void run() {}

b)

public abstract void run();

c)

public abstract void run() {}

d)

abstract run();

78.

23. What will this print?

abstract class Animal { abstract void sound(); }

class Cat extends Animal { void sound() { System.out.println("Meow"); } }

public class Test { public static void main(String[] args) { Animal a = new Cat(); a.sound(); } }

a)

A. Meow

b)

B. Bark

c)

C. Error

d)

D. No output

79.

24. Which is a valid way to access a static method?

a)

A. obj.method()

b)

B. ClassName.method()

c)

C. this.method()

d)

D. super.method()

80.

25. Why can't static methods use this?

a)

A. Because it’s private

b)

B. Because this refers to an instance, but static methods do not belong to an instance

c)

C. Because it’s undefined

d)

D. Because it’s final

81.

26. Code output?

interface Flyer { void fly(); }

class Bird implements Flyer { public void fly() { System.out.println("Bird is flying"); } }

public class Test { public static void main(String[] args) { Flyer f = new Bird(); f.fly(); } }

a)

A. Bird is flying

b)

B. Error

c)

C. Nothing

d)

D. Interface cannot be used

82.

27. Trace the output:

class A { public void display() { System.out.println("A"); } }

class B extends A { public void display() { System.out.println("B"); } }

public class Test { public static void main(String[] args) { A obj = new B(); obj.display(); } }

a)

A. A

b)

B. B

c)

C. AB

d)

D. Error

83.

28. Which is true about interfaces?

a)

A. They allow constructors

b)

B. They can implement classes

c)

C. They allow multiple inheritance

d)

D. They cannot be used polymorphically

84.

29. What happens if a method in subclass has the same signature as parent but different return type?

a)

A. It's valid overriding

b)

B. Compile-time error

c)

C. Runtime error

d)

D. Treated as overload

85.

30. What’s the result?

abstract class Vehicle { int year = 2020; abstract void display(); }

class Car extends Vehicle { void display() { System.out.println("Car made in " + year); } }

public class Test { public static void main(String[] args) { Vehicle v = new Car(); v.display(); } }

a)

A. Car made in 2020

b)

B. Vehicle

c)

C. Error

d)

D. Car

86.

REVISION 4

What happens if an exception is not caught in a try block?

a)

The program continues execution

b)

The program goes to the finally block and continues

c)

The program terminates abnormally

d)

The JVM retries the failed operation

87.

Which of the following exceptions is checked?

a)

ArithmeticException

b)

IOException

c)

NullPointerException

d)

ArrayIndexOutOfBoundsException

88.

Which keyword is used to declare that a method might throw an exception?

a)

throw

b)

throws

c)

catch

d)

finally

89.

What is the output of this code? int[] x = new int[2]; System.out.println(x[5]);

a)

0

b)

Compilation error

c)

java.lang.ArrayIndexOutOfBoundsException

d)

java.lang.NullPointerException

90.

What is the superclass of all errors and exceptions in Java?

a)

Exception

b)

Error

c)

RuntimeException

d)

Throwable

91.

The finally block is executed:

a)

Only when an exception is thrown

b)

Only if no exception is thrown

c)

Always

d)

Only if the catch block is executed

92.

What will happen if both catch and finally blocks contain return statements?

a)

The catch block’s return is used

b)

The finally block’s return is used

c)

Compilation error

d)

Unpredictable behavior

93.

What type of exception is NullPointerException?

a)

Checked

b)

Unchecked

c)

Logic error

d)

Compile-time error

94.

Identify the output:

try {int a = 10 / 0; }

catch (ArithmeticException e) { System.out.println("Catch"); }

finally {System.out.println("Finally");}

a)

Catch

b)

Finally

c)

Catch Finally

d)

Compilation error

95.

Which method provides the most detailed information about an exception stack?

a)

toString()

b)

getMessage()

c)

printStackTrace()

d)

getCause()

96.

Which of the following is not a runtime exception?

a)

NullPointerException

b)

ArithmeticException

c)

IOException

d)

ArrayIndexOutOfBoundsException

97.

What happens when you use throw without an exception object?

a)

Nothing

b)

Compilation error

c)

Runtime error

d)

Default exception is thrown

98.

In the following code, what exception will be thrown?

String[] arr = {"Java", "Network", "Maths"};

for(int i = 0; i < 4; i++){System.out.println(arr[i]); }

a)

NullPointerException

b)

ArrayIndexOutOfBoundsException

c)

ClassCastException

d)

No exception

99.

Which statement is true about throw and throws?

a)

Both are used for throwing exceptions

b)

throw is used in method header; throws in the body

c)

throw is used to throw; throws is used to declare

d)

throws is used for custom exceptions only

100.

What is the correct way to create a custom exception?

a)

class MyException extends Throwable

b)

class MyException extends RuntimeException

c)

class MyException extends Exception

d)

class MyException implements Exception

101.

How do you prevent a method from being overridden?

a)

Declare it as static

b)

Declare it as abstract

c)

Declare it as final

d)

Declare it as public

102.

Which of the following is NOT allowed in an interface?

a)

public abstract methods

b)

static final variables

c)

private constructors

d)

Implemented by classes

103.

Which is true about constructors in inheritance?

a)

Superclass constructor is inherited

b)

Subclass must define all constructors

c)

Superclass constructor is called explicitly or implicitly

d)

Superclass constructor is ignored

104.

What happens if you try to override a static method?

a)

It’s allowed

b)

It causes a compile error

c)

It hides the method, not override

d)

It overrides normally

105.

What does the implements keyword do?

a)

Inherit a class

b)

Implement a static method

c)

Adopt an interface’s method contracts

d)

None of the above

106.

What is true about the following class definition? public final class Bank { ... }

a)

It can be subclassed

b)

It cannot be instantiated

c)

It cannot be subclassed

d)

It must be abstract

107.

What is the purpose of super() in a constructor?

a)

Initializes local variables

b)

Calls current class constructor

c)

Calls superclass constructor

d)

Binds to abstract class

108.

Which of the following is valid multiple inheritance using interface?

public class Plane extends Vehicle, Animal implements Flyer { ... }

a)

Valid

b)

Invalid due to multiple classes

c)

Valid if Plane is abstract

d)

Valid if Flyer is abstract

109.

What does the abstract keyword imply for a method?

a)

It must return void

b)

It has implementation

c)

It has no implementation and must be overridden

d)

It can be private

110.

What is printed?

Vehicle v = new Aeroplane(200);

v.DisplayVehicleDetails();

a)

Compile-time error

b)

Aeroplane details including 200 passengers

c)

Vehicle

d)

Nothing