NEW
Font size
WorksheetsCODE ZENITH
Total questions: 15
Worksheet time: 9mins
Which keyword is used for inheritance in Java?
a) super
b) extends
c) implements
d) inheritance
What is the size of the int data type in Java?
a) 4 bytes
b) 8 bytes
c) 2 bytes
d) Depends on the system architecture
Which data structure in C is based on the Last In First Out (LIFO) principle?
a) Queue
b) Stack
c) Linked List
d) Tree
What is the default value of an integer variable in Java?
a) 0
b) 0.0
c) null
d) Depends on the compiler
In C language, which of the following is used to allocate memory dynamically?
a) malloc()
b) calloc()
c) realloc()
d) All of the above
What is the correct syntax for a multi-line comment in C?
a) /* comment */
b) // comment
c) # comment
d) ' comment '
What will be the output of the following Java code snippet?
int x = 5;
System.out.println(x++ + ++x);
a) 11
b) 12
c) 13
d) 14
In Python, what will be the output of the following code snippet?
x = "hello";
print(x[2:])
a) ello
b) hel
c) llo
d) lo
In Python, which of the following is used to define a block of code?
Parentheses {}
Square brackets []
Indentation
Quotations ""
In Java, what does the 'final' keyword signify?
The value cannot be changed
The class cannot be inherited
The method cannot be overridden
All of the above
What is the time complexity of the following Java code?
int count = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
count++;
}
}
O(n)
O(n log n)
O(n^2)
O(2^n)
In Python, what will be the output of the following code snippet?
def function_1(x):
return x * 2
def function_2(x):
return x + 2
def function_3(x):
return x - 2
x = 5
print(function_3(function_2(function_1(x))))
8
12
16
18
In Python, what will be the output of the following code snippet?
def outer_function(x):
def inner_function(y):
return x * y
return inner_function
double = outer_function(2)
triple = outer_function(3)
print(double(5) + triple(5))
25
30
35
40
What is the output of the following Java code?
public class Main {
public static void main(String[] args) {
int result = calculate(5);
System.out.println(result);
}
public static int calculate(int x) {
if (x == 0) {
return 0;
} else {
return x + calculate(x - 1);
}
}
}
Compilation Error
5
10
15
What will be the output of the following C code?
#include <stdio.h>
int main() {
int x = 5;
int *p = &x;
printf("%d", *p++);
return 0;
}
5
6
garbage value
error
