wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

OOPS

Total questions: 28

Worksheet time: 17mins

Name
Class
Date
1.

1. Which of the following best defines inheritance?

a)

A. Creating multiple objects

b)

B. Acquiring properties of one class into another

c)

C. Hiding implementation details

d)

D. Binding data and methods

2.

2. Which keyword is used to inherit a class in Java?

a)

A. implement

b)

B. inherits

c)

C. extends

d)

D. super

3.

3. Java supports which type(s) of inheritance?

a)

Single

b)

Multiple

c)

Hybrid

d)

Both A and B

4.

4. Which access modifier allows members to be inherited outside the package?

a)

private

b)

default

c)

protected

d)

final

5.

5. Constructors are inherited in Java.

a)

True

b)

False

c)

none

6.

6. Polymorphism means:

a)

One class many objects

b)

One method many forms

c)

One object many classes

d)

Many classes one object

7.

7. Method overloading is an example of:

a)

Runtime polymorphism

b)

Compile-time

c)

polymorphism

d)

Dynamic binding

Inheritance

8.

What is a data structure?

a)

A. Collection of programs

b)


B. Way to store and organize data

c)

C. Programming language

d)

D. Operating system

9.

Which of the following is a linear data structure?

a)

A. Tree

b)

B. Graph

c)

C. Array

d)

D. Heap

10.

Which data structure follows FIFO?

a)

A. Stack

b)

B. Queue

c)

C. Tree

d)

D. Graph

11.

Which data structure follows LIFO?

a)

A. Queue

b)

B. Array

c)

C. Stack

d)

D. Linked List

12.

What is the time complexity to access an element in an array?

a)

A. O(1)

b)

B. O(n)

c)

C. O(log n)

d)

D. O(n log n)

13.

Which operation is costly in arrays?

a)

A. Traversal

b)

B. Access

c)

C. Insertion

d)

D. Update

14.

Array size in Java is:

a)

A. Dynamic

b)

B. Static

c)

C. Fixed after creation

d)

D. Both B and C

15.

Which data structure uses pointers?

a)

A. Array

b)

B. Stack

c)

C. Linked List

d)

D. Queue

16.

Linked list elements are stored:

a)

A. Contiguously

b)

B. Randomly

c)

C. Sequentially in stack

d)

D. In tree form

17.

#include <stdio.h>

void main()

{

    int rate = 15, piece = 10, interim, result = 0;

    interim = rate % piece;

    result += interim / 5;

    printf("%d", result);

}

a)

A. 10

b)

B. 2

c)

C. 5

d)

D. 1

18.

What is the worst-case time complexity of linear search?

a)

A. O(1)

b)

B. O(log n)

c)

C. O(n)

d)

D. O(n log n)

19.

Which data structure is best suited for implementing undo and redo operations?

a)

A. Queue

b)

B. Array

c)

C. Stack

d)

D. Linked List

20.

What is the maximum number of children a binary tree node can have?

a)

A. 1

b)

B. 2

c)

C. 3

d)

D. Unlimited

21.

Which operation is not possible in a singly linked list?

a)

A. Traversal

b)

B. Insertion

c)

C. Deletion

d)

D. Backward traversal

22.

Which of the following is an application of stack?

a)

A. CPU scheduling

b)

B. Expression evaluation

c)

C. Level order traversal

d)

D. Graph coloring

23.

#include <stdio.h>

int main()

{

int a = 10;

printf("%d %d", a, ++a);

return 0;

}

a)

A. 10 11

b)

B. 11 11

c)

C. Undefined behavior

d)

D. Compilation error

24.

#include <stdio.h>

int main()

{

int a = 5, b = 10;

printf("%d", a > b ? a : b);

return 0;

}

a)

A. 5

b)

B. 10

c)

C. 0

d)

D. Error

25.

#include <stdio.h>

int main()

{

int i = 1;

while(i <= 3)

{

printf("%d", i);

i++;

}

return 0;

}

a)

A. 123

b)

B. 0123

c)

C. 321

d)

D. Infinite loop

26.

#include <stdio.h>

int main()

{

int a = 1;

printf("%d", sizeof(a++));

return 0;

}

a)

A. 1

b)

B. 2

c)

C. 4

d)

D. Depends on system

27.

#include <stdio.h>

int main()

{

int x = 10;

printf("%d", x == 10);

return 0;

}

a)

A. 10

b)

B. 1

c)

C. 0

d)

D. Error

28.

#include <stdio.h>

int main()

{

int i = 0;

for(; i < 5; i++);

printf("%d", i);

return 0;

}

a)

A. 4

b)

B. 5

c)

C. 0

d)

D. Infinite loop