wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Object-Oriented Programming Concepts Worksheet (Transcribed)

Total questions: 113

Worksheet time: 57mins

Name
Class
Date
1.

A hospital system creates patient objects dynamically at runtime. Where are these objects stored?

a)

Heap memory

b)

Stack memory

c)

Register

d)

Method area

2.

A banking app must not allow interest rate value to change once set. Which keyword enforces this?

a)

final

b)

static

c)

abstract

d)

protected

3.

A class is designed only to be inherited and not instantiated. Which type is suitable?

a)

Abstract class

b)

Interface

c)

Package

d)

Enum

4.

A billing system defines calculateBill() with different parameter types. Which concept is used?

a)

Method overloading

b)

Method overriding

c)

Encapsulation

d)

Polymorphism

5.

An ATM software hides internal cash calculation logic from users. Which principle is applied?

a)

Encapsulation

b)

Inheritance

c)

Polymorphism

d)

Abstraction

6.

A weather system stores temperature readings of 31 days. Which structure is efficient?

a)

Array

b)

Single variable

c)

Interface

d)

Class

7.

A chat server updates message content frequently. Which class should be used?

a)

StringBuilder

b)

String

c)

Character

d)

Array

8.

A gaming app uses different attack behaviors for different characters at runtime. Which concept supports this?

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Abstraction

9.

A login module must run validation at least once before checking condition. Which loop fits?

a)

do-while

b)

while

c)

for

d)

switch

10.

A payroll system extends Employee class to Manager class. Which keyword is used?

a)

extends

b)

implements

c)

super

d)

this

11.

A project organizes related classes into logical folders. Which feature is used?

a)

Package

b)

Interface

c)

JVM

d)

JRE

12.

A base reference calls a subclass method at runtime. Which binding occurs?

a)

Dynamic binding

b)

Static binding

c)

Method hiding

d)

Constructor chaining

13.

A utility class must not be inherited for security reasons. Which keyword is used?

a)

final

b)

static

c)

native

d)

transient

14.

A finance app converts integer input to double automatically during calculation. What is this?

a)

Type conversion

b)

Inheritance

c)

Polymorphism

d)

Encapsulation

15.

A drawing app forces all shapes to define draw(). Which is best?

a)

Interface

b)

Abstract class

c)

Package

d)

Final class

16.

A menu-driven railway system has fixed options. Which structure is suitable?

a)

switch

b)

if

c)

while

d)

for

17.

A subclass constructor executes after parent constructor. Which concept explains this?

a)

Constructor chaining

b)

Method overriding

c)

Polymorphism

d)

Static binding

18.

A text editor modifies content frequently. Which class avoids extra object creation?

a)

StringBuffer

b)

String

c)

Character

d)

Array

19.

An online service standardizes function names across modules. Which construct helps?

a)

Interface

b)

Package

c)

JVM

d)

Enum

20.

A reporting tool allows different formats using same method name. Which concept is applied?

a)

Method overriding

b)

Method overloading

c)

Encapsulation

d)

Packages

21.

A sensor system stores multiple readings and sums them. Which structure is best?

a)

Array with loop

b)

Single variable

22.

A class should provide partial implementation and force remaining methods. Which is ideal?

a)

Abstract class

b)

Interface

c)

Package

d)

Final class

23.

A class should follow a contract but share no code. Which is used?

a)

Interface

b)

Abstract class

c)

Package

d)

JVM

24.

A compiler converts source to bytecode. Which tool performs this?

a)

javac

b)

JVM

c)

JRE

d)

JIT

25.

A runtime environment executes bytecode. Which component handles this?

a)

JVM

b)

JDK

c)

JIT

d)

Compiler

26.

A class contains variables and methods together. Which concept is used?

a)

Encapsulation

b)

Polymorphism

c)

Abstraction

d)

Inheritance

27.

A class hides internal logic and exposes only essential features. Which principle applies?

a)

Abstraction

b)

Inheritance

c)

Polymorphism

d)

Encapsulation

28.

An object reference changes behavior based on actual object type. Which concept?

a)

Polymorphism

b)

Encapsulation

c)

Abstraction

d)

Inheritance

29.

A company groups payroll-related classes separately. Which feature supports this?

a)

Packages

b)

Interfaces

c)

JVM

d)

JRE

30.

A program must ensure one-time execution before loop condition. Which loop?

a)

do-while

b)

while

c)

for

d)

switch

31.

A program uses multiple constructors in a class. Which concept is this?

a)

Constructor overloading

b)

Method overriding

c)

Polymorphism

d)

Inheritance

32.

A base class method is replaced in subclass. Which is applied?

a)

Method overriding

b)

Method overloading

c)

Abstraction

d)

Encapsulation

33.

A real-time system selects method at runtime. Which mechanism?

a)

Dynamic binding

b)

Static binding

c)

Method hiding

d)

Constructor chaining

34.

A utility method works for int and double inputs. Which concept is used?

a)

Method overloading

b)

Method overriding

c)

Packages

d)

Inheritance

35.

A student system prevents class inheritance. Which keyword?

a)

final

b)

static

c)

protected

d)

abstract

36.

A program runs same code on Windows and Linux. Which feature enables this?

a)

Bytecode on JVM

b)

Pointers

c)

Native compiler

d)

Hardware execution

37.

A loop repeats until user enters correct input. Which loop is ideal?

a)

do-while

b)

for

c)

if

d)

switch

38.

A program stores 2D marks list. Which structure is used?

a)

Multidimensional array

b)

Single array

c)

Interface

d)

Abstract class

39.

A library app hides book ID from user. Which access control helps?

a)

private

b)

public

c)

default

d)

protected

40.

A subclass uses parent variable. Which keyword accesses it?

a)

super

b)

this

c)

static

d)

final

41.

A method accepts unlimited parameters. Which feature is used?

a)

Varargs

b)

Overloading

c)

Overriding

d)

Constructor

42.

A program must prevent method modification. Which keyword is used?

a)

final

b)

static

43.

A class inside another class improves modularity. Which is this?

a)

Inner class

b)

Interface

c)

Package

d)

Enum

44.

A method is implemented directly inside argument. Which type is this?

a)

Anonymous class

b)

Inner class

c)

Abstract class

d)

Interface

45.

A class belongs to predefined library. Which package contains it?

a)

java.lang

b)

java.io

c)

java.sql

d)

java.util

46.

A program chooses among multiple fixed options. Which structure?

a)

switch

b)

for

c)

while

d)

if only

47.

A compiler warns when method signature mismatch occurs. Which rule is violated?

a)

Overriding rule

b)

Overloading rule

c)

Package rule

d)

JVM rule

48.

A program stores user details with attributes and behavior. Which structure is used?

a)

Class

b)

Interface

c)

Package

d)

Method

49.

An app ensures data hiding from external access. Which principle?

a)

Encapsulation

b)

Abstraction

c)

Polymorphism

d)

Inheritance

50.

A program avoids multiple inheritance of classes but allows behavior sharing. Which feature?

a)

Interface

b)

Abstract class

c)

Package

d)

JVM

51.

A company application stores employee details and behavior together. Which construct is used?

a)

Class

b)

Interface

c)

Package

d)

Method

52.

A mobile app restricts modification of configuration values. Which keyword ensures this?

a)

final

b)

static

c)

protected

d)

abstract

53.

A framework forces subclasses to implement required methods but shares common logic. Which design fits?

a)

Abstract class

b)

Interface

c)

Package

d)

Enum

54.

A graphics system defines draw() differently for Circle and Rectangle at runtime. Which concept applies?

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Abstraction

55.

A data analytics program stores daily sales values efficiently. Which structure is best?

a)

Array

b)

Single variable

c)

Interface

d)

Abstract class

56.

A chat application modifies text continuously. Which class improves performance?

a)

StringBuilder

b)

String

c)

Character

d)

Array

57.

A base reference calls overridden method of subclass. Which mechanism resolves this?

a)

Dynamic binding

b)

Static binding

c)

Method hiding

d)

Constructor chaining

58.

A class prevents object creation but provides method definitions. Which is used?

a)

Abstract class

b)

Interface

c)

Concrete class

d)

Package

59.

A hospital system groups doctor-related classes separately. Which feature helps?

a)

Packages

b)

JVM

c)

JRE

d)

Interface

60.

A calculator supports add(int,int) and add(double,double). Which concept is used?

a)

Method overloading

b)

Method overriding

c)

Polymorphism

d)

Encapsulation

61.

A security module blocks subclass creation for sensitive classes. Which keyword is used?

a)

final

b)

static

c)

private

d)

abstract

62.

A payroll program executes the same code on Windows and Linux. Which feature enables this?

a)

JVM bytecode execution

b)

Native compiler

c)

Pointer usage

d)

Hardware execution

63.

A menu-driven program executes at least once before condition check. Which loop suits?

a)

do-while

b)

while

64.

A company stores matrix of monthly expenses. Which structure is used?

a)

Multidimensional array

b)

Single array

c)

Interface

d)

Abstract class

65.

A method accepts unlimited number of arguments. Which feature is used?

a)

Varargs

b)

Overloading

c)

Overriding

d)

Constructor

66.

A banking app hides account balance from external access. Which access modifier is suitable?

a)

private

b)

public

c)

default

d)

protected

67.

A subclass accesses parent class variable. Which keyword is used?

a)

super

b)

this

c)

static

d)

final

68.

A class is nested inside another class for better organization. Which type is this?

a)

Inner class

b)

Interface

c)

Package

d)

Enum

69.

A method is implemented without creating a named class. Which type is used?

a)

Anonymous class

b)

Abstract class

c)

Interface

d)

Package

70.

A program uses predefined core classes like String and Math. Which package contains them?

a)

java.lang

b)

java.util

c)

java.io

d)

java.sql

71.

A system groups billing-related classes logically. Which feature helps?

a)

Packages

b)

Inheritance

c)

Polymorphism

d)

JVM

72.

A base class method is replaced by subclass method. Which concept applies?

a)

Method overriding

b)

Method overloading

c)

Encapsulation

d)

Abstraction

73.

A utility method handles both integer and float inputs. Which feature supports this?

a)

Method overloading

b)

Method overriding

c)

Inheritance

d)

Package

74.

A loop repeats until valid input is entered. Which structure is ideal?

a)

do-while

b)

for

c)

switch

d)

if

75.

A class prevents modification of its method. Which keyword is used?

a)

final

b)

static

c)

native

d)

volatile

76.

A Java program chooses from multiple fixed menu options. Which structure is best?

a)

switch

b)

for

c)

while

d)

if only

77.

A system stores user data and operations together. Which principle applies?

a)

Encapsulation

b)

Polymorphism

c)

Abstraction

d)

Inheritance

78.

A system exposes only essential features and hides internal details. Which principle applies?

a)

Abstraction

b)

Inheritance

c)

Polymorphism

d)

Encapsulation

79.

A base reference refers to derived object at runtime. Which concept is demonstrated?

a)

Polymorphism

b)

Inheritance

c)

Abstraction

d)

Encapsulation

80.

A program ensures one-time initialization before loop execution. Which loop fits?

a)

do-while

b)

while

c)

for

d)

switch

81.

A class contains multiple constructors with different parameters. Which concept is used?

a)

Constructor overloading

b)

Method overriding

c)

Inheritance

d)

Polymorphism

82.

A drawing application forces shapes to define draw(). Which is suitable?

a)

Interface

b)

Abstract class

c)

Package

d)

Enum

83.

A utility class should not be instantiated. Which keyword supports this?

a)

abstract

b)

static

c)

native

d)

transient

84.

A student system converts int marks to double automatically. What is this?

a)

Type conversion

b)

Polymorphism

85.

A system organizes reusable modules logically. Which feature helps?

a)

Packages

b)

Interface

c)

JVM

d)

Enum

86.

A subclass calls parent constructor first. Which concept explains this?

a)

Constructor chaining

b)

Method hiding

c)

Static binding

d)

Polymorphism

87.

A method executes based on actual object type at runtime. Which is this?

a)

Dynamic binding

b)

Static binding

c)

Method hiding

d)

Constructor chaining

88.

A class should share code and force method implementation. Which design fits?

a)

Abstract class

b)

Interface

c)

Package

d)

Enum

89.

A class should only define behavior contract. Which is best?

a)

Interface

b)

Abstract class

c)

Package

d)

JVM

90.

A system must avoid name conflict across modules. Which feature helps?

a)

Packages

b)

Polymorphism

c)

Inheritance

d)

JVM

91.

A real-time app selects implementation based on object type. Which concept applies?

a)

Polymorphism

b)

Encapsulation

c)

Abstraction

d)

Inheritance

92.

A program prevents further inheritance of a class. Which keyword is used?

a)

final

b)

static

c)

native

d)

protected

93.

A method accepts multiple inputs of same type. Which feature supports this?

a)

Varargs

b)

Overloading

c)

Overriding

d)

Constructor

94.

A class hides its variables from outside world. Which modifier is used?

a)

private

b)

public

c)

protected

d)

default

95.

A subclass uses parent class method directly. Which keyword is used?

a)

super

b)

this

c)

static

d)

final

96.

A text editor frequently updates strings. Which class is best?

a)

StringBuffer

b)

String

c)

Character

d)

Array

97.

A software enforces same method name across different classes. Which construct is used?

a)

Interface

b)

Abstract class

c)

Package

d)

JVM

98.

A Java program must ensure at least one execution of loop. Which is used?

a)

do-while

b)

while

c)

for

d)

switch

99.

A system groups utility classes logically. Which feature helps?

a)

Packages

b)

Polymorphism

c)

Inheritance

d)

JVM

100.

A software system allows extension without modifying existing code. Which concept supports this?

a)

Polymorphism

b)

Encapsulation

c)

Inheritance

d)

Arrays

101.

User authentication check: Consider the following Java code. class Test { public static void main(String[] args) { String user = "admin"; if(user == "admin") System.out.print("Login"); else System.out.print("Fail"); } } What is the program output?

a)

Login

b)

Fail

c)

Runtime error

d)

Compilation error

102.

Banking balance update: Consider the following Java code. class Bank { int balance = 1000; void update(int balance){ balance = balance + 500; } public static void main(String[] args){ Bank b = new Bank(); b.update(b.balance); System.out.print(b.balance); } } What is printed?

a)

1500

b)

1000

c)

500

d)

Error

103.

Hospital patient counter: Consider the following Java code. class Hospital { static int count = 0; Hospital(){ count++; } public static void main(String[] args){ new Hospital(); new Hospital(); System.out.print(count); } } What is the output?

a)

0

b)

1

c)

2

d)

Error

104.

Online order processing: Consider the following Java code. class Order { public static void main(String[] args){ int x = 10; System.out.print(x++ + ++x); } } What is the output?

a)

21

b)

22

c)

20

d)

23

105.

IoT sensor reading: Consider the following Java code. class Sensor { public static void main(String[] args){ int[] temp = {30,31,32}; System.out.print(temp[3]); } } What happens when the program runs?

a)

32

b)

31

c)

ArrayIndexOutOfBoundsException

d)

Compilation error

106.

Game character attack: Consider the following Java code. class A { void attack(){ System.out.print("Punch"); } } class B extends A{ void attack(){ System.out.print("Kick"); } } public class Test{ public static void main(String[] args){ A obj = new B(); obj.attack(); } } What is printed?

a)

Punch

b)

Kick

c)

PunchKick

d)

Error

107.

Railway ticket price: Consider the following Java code. class Ticket { static int price = 50; public static void main(String[] args){ Ticket t1 = new Ticket(); Ticket t2 = new Ticket(); t1.price = 100; System.out.print(t2.price); } } What is the output?

a)

50

b)

100

c)

0

d)

Error

108.

Student marks: Consider the following Java code. class Marks { public static void main(String[] args){ int a = 5; int b = 2; System.out.print(a/b); } } What is printed?

a)

2

b)

2.5

c)

3

d)

Error

109.

File processing: Consider the following Java code. class FileTest { public static void main(String[] args){ String s = "Java"; s.concat("World"); System.out.print(s); } } What is the output?

a)

Java

b)

JavaWorld

c)

World

d)

Error

110.

Login attempts: Consider the following Java code. class Login { public static void main(String[] args){ int i = 0; do{ System.out.print(i); i++; }while(i<3); } } What does the program print?

a)

012

b)

123

c)

0123

d)

01

111.

Cloud server counter: Consider the following Java code. class Server { static int x = 10; public static void main(String[] args){ Server s1 = new Server(); s1.x++; Server s2 = new Server(); s2.x++; System.out.print(x); } } What is the output?

a)

10

b)

11

c)

12

d)

13

112.

Shopping cart. Consider the Java code: class Cart { public static void main(String[] args){ String s1 = "Shop"; String s2 = new String("Shop"); System.out.print(s1 == s2); } } Choose the correct output.

a)

true

b)

false

c)

Shop

d)

Error

113.

ATM pin check. Consider the Java code: class ATM { public static void main(String[] args){ int pin = 1234; if(pin = 1234) System.out.print("Valid"); } } Choose the correct outcome for compilation/execution.

a)

Valid

b)

Invalid

c)

Compilation error

d)

Runtime error