wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CODE RIDDLE

Total questions: 40

Worksheet time: 30mins

Name
Class
Date
1.

Which of the following is the correct format specifier to print an integer in C?

a)

%f

b)

%d

c)

%c

d)

%s

2.

Which keyword is used to inherit a class in Java?

a)

super

b)

this

c)

extends

d)

implements

3.

What is the output of the following code? x = "Hello" print(len(x))

a)

4

b)

5

c)

6

d)

Error

4.

Which data structure is best suited for implementing recursion?

a)

Queue

b)

Stack

c)

Linked List

d)

Binary Tree

5.

Which of these concepts is NOT supported in Java?

a)

Multiple inheritance using classes

b)

Abstraction

c)

Polymorphism

d)

Encapsulation

6.

Which function is used to read a string from the user in C?

a)

scanf()

b)

gets()

c)

printf()

d)

puts()

7.

Which data structure uses FIFO principle?

a)

Stack

b)

Queue

c)

Linked List

d)

Tree

8.

Which operator gives the address of a variable?

a)

&

b)

*

c)

%

d)

#

9.

Which SQL keyword is used to remove duplicate rows in the output?

a)

UNIQUE

b)

DISTINCT

c)

REMOVE

d)

DIFFERENT

10.

Which data structure uses LIFO principle?

a)

Stack

b)

Queue

c)

Linked List

d)

Tree

11.

Default value of boolean variable in Java?

a)

true

b)

false

c)

0

d)

null

12.

Which of these is dynamic data structure?

a)

Array

b)

Linked List

c)

Stack

d)

Queue

13.

Which exception is thrown when dividing by zero?

a)

ArithmeticException

b)

NullPointerException

c)

IOException

d)

RuntimeException

14.

In ER model, a weak entity is one that:

a)

Has no primary key

b)

Depends on strong entity for identification

c)

Both A and B

d)

None

15.

What is function pointer?

a)

Pointer to data

b)

Pointer to array

c)

Pointer to function's address

d)

Pointer to struct

16.

What is the output? a = (1,2,[3,4]) a[2][0] = 99 print(a)

a)

Error

b)

(1,2,[3,4])

c)

(1,2,[99,4])

d)

None

17.

Which of these is used to handle exceptions in Python?

a)

catch-finally

b)

try-except

c)

do-catch

d)

handle-error

18.

What is the result? int a=5; printf("%d %d %d", a, ++a, a++);

a)

5 6 6

b)

5 6 7

c)

Undefined behavior

d)

5 7 6

19.

Which SQL clause is applied after GROUP BY?

a)

WHERE

b)

HAVING

c)

ORDER BY

d)

LIMIT

20.

Which of these functions is used to dynamically allocate memory?

a)

malloc()

b)

alloc()

c)

create()

d)

memalloc()

21.

What is the output? x = [1,2,3] y = x y.append(4) print(x)

a)

[1,2,3]

b)

[1,2,3,4]

c)

Error

d)

None

22.

In SQL, which command is used to remove a table definition permanently?

a)

DELETE

b)

TRUNCATE

c)

DROP

d)

REMOVE

23.

Which of the following ensures that no foreign key value can exist without a corresponding primary key?

a)

Referential Integrity

b)

Domain Integrity

c)

Entity Integrity

d)

Functional Dependency

24.

What is the output? printf("%d", 'A');

a)

65

b)

A

c)

Error

d)

97

25.

Which concept prevents method overriding in Java?

a)

abstract

b)

static

c)

final

d)

synchronized

26.

ASCII code of digit '0' is:

a)

47

b)

48

c)

65

d)

97

27.

Which traversal method is best to copy a binary tree?

a)

Preorder

b)

Inorder

c)

Postorder

d)

Level order

28.

Which function is used to compare two strings in C?

a)

strcmp()

b)

strcomp()

c)

strcompare()

d)

compare()

29.

Which key is used to uniquely identify a row in a relation?

a)

Foreign key

b)

Primary key

c)

Candidate key

d)

Alternate key

30.

Which exception is checked at compile time?

a)

NullPointerException

b)

IOException

c)

ArithmeticException

d)

ArrayIndexOutOfBounds

31.

what will be the Output? a = {1,2,3} b = {3,4,5} print(a & b)

a)

{1,2,3,4,5}

b)

{3}

c)

{1,2}

d)

Error

32.

Which of the following is NOT a valid join?

a)

Outer Join

b)

Cross Join

c)

Natural Join

d)

Foreign Join

33.

Which collection doesn't allow duplicates?

a)

List

b)

Set

c)

ArrayList

d)

LinkedList

34.

Which of the following is immutable?

a)

List

b)

Set

c)

Tuple

d)

Dictionary

35.

Which design principle is violated if multiple classes depend on volatile fields?

a)

Encapsulation

b)

Single Responsibility

c)

Open/Closed

d)

Liskov Substitution

36.

Which operator has the highest precedence in C?

a)

* (multiplication)

b)

++ (increment)

c)

= (assignment)

d)

&& (logical AND)

37.

Which of these interfaces does Collection extend in Java?

a)

Iterator

b)

Iterable

c)

Enumeration

d)

List

38.

Which of these ensures no phantom reads in transactions?

a)

Read Uncommitted

b)

Read Committed

c)

Repeatable Read

d)

Serializable

39.

What is ASCII value of uppercase Z?

a)

90

b)

91

c)

65

d)

97

40.

What is the postfix of (A + B) * (C - D)?

a)

AB+CD-*

b)

AB+CD-

c)

ABCD+-

d)

AB*CD+-