WorksheetsOOPS
Total questions: 28
Worksheet time: 17mins
1. Which of the following best defines inheritance?
A. Creating multiple objects
B. Acquiring properties of one class into another
C. Hiding implementation details
D. Binding data and methods
2. Which keyword is used to inherit a class in Java?
A. implement
B. inherits
C. extends
D. super
3. Java supports which type(s) of inheritance?
Single
Multiple
Hybrid
Both A and B
4. Which access modifier allows members to be inherited outside the package?
private
default
protected
final
5. Constructors are inherited in Java.
True
False
none
6. Polymorphism means:
One class many objects
One method many forms
One object many classes
Many classes one object
7. Method overloading is an example of:
Runtime polymorphism
Compile-time
polymorphism
Dynamic binding
Inheritance
What is a data structure?
A. Collection of programs
B. Way to store and organize data
C. Programming language
D. Operating system
Which of the following is a linear data structure?
A. Tree
B. Graph
C. Array
D. Heap
Which data structure follows FIFO?
A. Stack
B. Queue
C. Tree
D. Graph
Which data structure follows LIFO?
A. Queue
B. Array
C. Stack
D. Linked List
What is the time complexity to access an element in an array?
A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Which operation is costly in arrays?
A. Traversal
B. Access
C. Insertion
D. Update
Array size in Java is:
A. Dynamic
B. Static
C. Fixed after creation
D. Both B and C
Which data structure uses pointers?
A. Array
B. Stack
C. Linked List
D. Queue
Linked list elements are stored:
A. Contiguously
B. Randomly
C. Sequentially in stack
D. In tree form
#include <stdio.h>
void main()
{
int rate = 15, piece = 10, interim, result = 0;
interim = rate % piece;
result += interim / 5;
printf("%d", result);
}
A. 10
B. 2
C. 5
D. 1
What is the worst-case time complexity of linear search?
A. O(1)
B. O(log n)
C. O(n)
D. O(n log n)
Which data structure is best suited for implementing undo and redo operations?
A. Queue
B. Array
C. Stack
D. Linked List
What is the maximum number of children a binary tree node can have?
A. 1
B. 2
C. 3
D. Unlimited
Which operation is not possible in a singly linked list?
A. Traversal
B. Insertion
C. Deletion
D. Backward traversal
Which of the following is an application of stack?
A. CPU scheduling
B. Expression evaluation
C. Level order traversal
D. Graph coloring
#include <stdio.h>
int main()
{
int a = 10;
printf("%d %d", a, ++a);
return 0;
}
A. 10 11
B. 11 11
C. Undefined behavior
D. Compilation error
#include <stdio.h>
int main()
{
int a = 5, b = 10;
printf("%d", a > b ? a : b);
return 0;
}
A. 5
B. 10
C. 0
D. Error
#include <stdio.h>
int main()
{
int i = 1;
while(i <= 3)
{
printf("%d", i);
i++;
}
return 0;
}
A. 123
B. 0123
C. 321
D. Infinite loop
#include <stdio.h>
int main()
{
int a = 1;
printf("%d", sizeof(a++));
return 0;
}
A. 1
B. 2
C. 4
D. Depends on system
#include <stdio.h>
int main()
{
int x = 10;
printf("%d", x == 10);
return 0;
}
A. 10
B. 1
C. 0
D. Error
#include <stdio.h>
int main()
{
int i = 0;
for(; i < 5; i++);
printf("%d", i);
return 0;
}
A. 4
B. 5
C. 0
D. Infinite loop
