wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CODE ZENITH

Total questions: 15

Worksheet time: 9mins

Name
Class
Date
1.

Which keyword is used for inheritance in Java?

a)

a) super

b)

b) extends

c)

c) implements

d)

d) inheritance

2.

What is the size of the int data type in Java?

a)

a) 4 bytes

b)

b) 8 bytes

c)

c) 2 bytes

d)

d) Depends on the system architecture

3.

Which data structure in C is based on the Last In First Out (LIFO) principle?

a)

a) Queue

b)

b) Stack

c)

c) Linked List

d)

d) Tree

4.

What is the default value of an integer variable in Java?

a)

a) 0

b)

b) 0.0

c)

c) null

d)

d) Depends on the compiler

5.

In C language, which of the following is used to allocate memory dynamically?

a)

a) malloc()

b)

b) calloc()

c)

c) realloc()

d)

d) All of the above

6.

What is the correct syntax for a multi-line comment in C?

a)

a) /* comment */

b)

b) // comment

c)

c) # comment

d)

d) ' comment '

7.

What will be the output of the following Java code snippet?

int x = 5;

System.out.println(x++ + ++x);

a)

a) 11

b)

b) 12

c)

c) 13

d)

d) 14

8.

In Python, what will be the output of the following code snippet?

x = "hello";

print(x[2:])

a)

a) ello

b)

b) hel

c)

c) llo

d)

d) lo

9.

In Python, which of the following is used to define a block of code?

a)

Parentheses {}

b)

Square brackets []

c)

Indentation

d)

Quotations ""

10.

In Java, what does the 'final' keyword signify?

a)

The value cannot be changed

b)

The class cannot be inherited

c)

The method cannot be overridden

d)

All of the above

11.

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++;

}

}

a)

O(n)

b)

O(n log n)

c)

O(n^2)

d)

O(2^n)

12.

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))))

a)

8

b)

12

c)

16

d)

18

13.

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))

a)

25

b)

30

c)

35

d)

40

14.

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);

}

}

}

a)

Compilation Error

b)

5

c)

10

d)

15

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;

}

a)

5

b)

6

c)

garbage value

d)

error