wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Symposium Round 1

Total questions: 31

Worksheet time: 16mins

Name
Class
Date
1.

Which of the following is the correct way to create a list in Python?

a)

list = {1, 2, 3}

b)

list = [1, 2, 3]

c)

list = (1, 2, 3)

d)

list = <1, 2, 3>

2.

#include <stdio.h>

int main() {

int a = 5;

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

return 0;

}

a)

6 5 7

b)

6 6 7

c)

7 6 7

d)

Output is undefined/implementation dependent

3.

Which keyword is used to create a class in Java?

a)

create

b)

class

c)

new

d)

object

4.

What is the correct syntax to include a header file in C?

a)

#include "stdio.h"

b)

#include <stdio.h>

c)

include <stdio.h>

d)

Both A and B are correct

5.

What will be the output of the following Java code?

public class Test {

static int x = 10;

static {

x = 20;

System.out.print(x + " ");

}

public static void main(String[] args) {

System.out.print(x + " ");

x = 30;

new Test();

System.out.print(x);

}

{

x = 40;

System.out.print(x + " ");

}

}

a)

20 20 40 30

b)

20 20 30 40

c)

10 20 40 30

d)

20 30 40 40

6.

What is the output of:

print(type(5.0))?

a)

<class 'int'>

b)

<class 'float'>

c)

<class 'double'>

d)

<class 'number'>

7.

Which of these is NOT a primitive data type in Java?

a)

int

b)

String

c)

boolean

d)

char

8.

What does the sizeof() operator return in C?

a)

The value of the variable

b)

The address of the variable

c)

The size in bytes

d)

The type of the variable

9.

def func(a, b=[]):

b.append(a)

return b

print(func(1))

print(func(2))

print(func(3, []))

a)

[1] [2] [3]

b)

[1] [1, 2] [3]

c)

[1] [2] [3]

d)

[1] [1, 2] [1, 2, 3]

10.

Which operator is used for exponentiation in Python?

a)

^

b)

**

c)

pow()

d)

Both B and C

11.

x = [1, 2, 3]

y = x

y.append(4)

print(x)

a)

[1, 2, 3]

b)

[1, 2, 3, 4]

c)

[4]

d)

Error

12.

#include <stdio.h>

int main() {

char arr[] = "hello";

char *ptr = arr;

printf("%c %c %c", ptr++, ++ptr, *ptr++);

return 0;

}

a)

h e l

b)

h l l

c)

l l o

d)

Output is undefined

13.

String s1 = "Java";

String s2 = new String("Java");

System.out.println(s1 == s2);

System.out.println(s1.equals(s2));

a)

true, true

b)

false, false

c)

true, false

d)

false, true

14.

#include <stdio.h>

int main() {

int a[] = {1, 2, 3, 4, 5};

int *p = &a[2];

printf("%d", *(p - 1));

return 0;

}

a)

1

b)

2

c)

3

d)

Compilation error

15.

def decorator(func):

def wrapper(*args, **kwargs):

print("Before")

result = func(*args, **kwargs)

print("After")

return result

return wrapper

@decorator

def greet(name):

print(f"Hello {name}")

greet("World")

a)

Hello World

b)

Before\nHello World\nAfter

c)

Before\nAfter\nHello World

d)

Error

16.

public class Test {

private static int count = 0;

public Test() {

count++;

}

public static void main(String[] args) {

Test t1 = new Test();

Test t2 = new Test();

System.out.println(t1.count + " " + t2.count);

}

}

a)

1 1

b)

1 2

c)

2 2

d)

0 0

17.

#include <stdio.h>

int main() {

int x = 5;

int y = x++ + ++x;

printf("%d %d", x, y);

return 0;

}

a)

7 12

b)

7 11

c)

6 11

d)

Undefined behavior

18.

class Parent:

def init(self):

self.value = "Parent"

def show(self):

print(self.value)

class Child(Parent):

def init(self):

super().__init__()

self.value = "Child"

obj = Child()

obj.show()

a)

Parent

b)

Child

c)

Parent Child

d)

Error

19.

class Meta(type):

def new(cls, name, bases, attrs):

attrs['class_id'] = f"{name}_v1"

return super().__new__(cls, name, bases, attrs)

class MyClass(metaclass=Meta):

pass

print(MyClass.class_id)

print(type(MyClass))

a)

MyClass_v1\n<class 'type'>

b)

MyClass_v1\n<class 'main.Meta'>

c)

Error

d)

None\n<class 'type'>

20.

public class Example {

public static void main(String[] args) {

try {

int result = 10 / 0;

System.out.println("Result: " + result);

} catch (ArithmeticException e) {

System.out.println("Caught exception");

} finally {

System.out.println("Finally block");

}

}

}

a)

Result: infinity\nFinally block

b)

Caught exception\nFinally block

c)

Finally block

d)

Program crashes

21.

x = [1, 2, 3]

y = x[:]

y.append(4)

print(len(x), len(y))

a)

3 3

b)

4 4

c)

3 4

d)

4 3

22.

What is the correct way to declare a constant in C?

a)

constant int x = 5;

b)

const int x = 5;

c)

final int x = 5;

d)

readonly int x = 5;

23.

public class Test {

static {

System.out.print("A");

}

{

System.out.print("B");

}

public Test() {

System.out.print("C");

}

public static void main(String[] args) {

System.out.print("D");

new Test();

new Test();

}

}

a)

ABCBC

b)

ADBCBC

c)

DABCBC

d)

DBCBC

24.

Which of the following is the correct syntax to define a function in Python?

a)

function myFunc():

b)

def myFunc():

c)

define myFunc():

d)

func myFunc():

25.

#include <stdio.h>

int main() {

int a = 5, b = 2;

printf("%.2f", (float)a/b);

return 0;

}

a)

2.50

b)

2.00

c)

2

d)

2.5

26.

class A:

def init(self):

print("A")

def new(cls):

print("Creating A")

return super().__new__(cls)

obj = A()

a)

A

b)

Creating A

c)

Creating A\nA

d)

Error

27.

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

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

Platform dependent

28.

public class Example {

public static void main(String[] args) {

String str = "Hello";

str.concat(" World");

System.out.println(str);

}

}

a)

Hello World

b)

Hello

c)

World

d)

Compilation error

29.

#include <stdio.h>

#define SQUARE(x) x*x

int main() {

int result = SQUARE(3+2);

printf("%d", result);

return 0;

}

a)

25

b)

11

c)

10

d)

9

30.

Java: String str = new String("Hello");

Python: my_list = [1, 2, 3]

C: int *ptr = malloc(sizeof(int));

a)

All three require manual memory deallocation

b)

Java and Python use garbage collection, C requires manual deallocation

c)

Only Java uses garbage collection

d)

All three use automatic garbage collection

31.

3+3

a)

1

b)

5

c)

9

d)

6