NEW
Font size
WorksheetsSymposium Round 1
Total questions: 31
Worksheet time: 16mins
Which of the following is the correct way to create a list in Python?
list = {1, 2, 3}
list = [1, 2, 3]
list = (1, 2, 3)
list = <1, 2, 3>
#include <stdio.h>
int main() {
int a = 5;
printf("%d %d %d", ++a, a++, a);
return 0;
}
6 5 7
6 6 7
7 6 7
Output is undefined/implementation dependent
Which keyword is used to create a class in Java?
create
class
new
object
What is the correct syntax to include a header file in C?
#include "stdio.h"
#include <stdio.h>
include <stdio.h>
Both A and B are correct
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 + " ");
}
}
20 20 40 30
20 20 30 40
10 20 40 30
20 30 40 40
What is the output of:
print(type(5.0))?
<class 'int'>
<class 'float'>
<class 'double'>
<class 'number'>
Which of these is NOT a primitive data type in Java?
int
String
boolean
char
What does the sizeof() operator return in C?
The value of the variable
The address of the variable
The size in bytes
The type of the variable
def func(a, b=[]):
b.append(a)
return b
print(func(1))
print(func(2))
print(func(3, []))
[1] [2] [3]
[1] [1, 2] [3]
[1] [2] [3]
[1] [1, 2] [1, 2, 3]
Which operator is used for exponentiation in Python?
^
**
pow()
Both B and C
x = [1, 2, 3]
y = x
y.append(4)
print(x)
[1, 2, 3]
[1, 2, 3, 4]
[4]
Error
#include <stdio.h>
int main() {
char arr[] = "hello";
char *ptr = arr;
printf("%c %c %c", ptr++, ++ptr, *ptr++);
return 0;
}
h e l
h l l
l l o
Output is undefined
String s1 = "Java";
String s2 = new String("Java");
System.out.println(s1 == s2);
System.out.println(s1.equals(s2));
true, true
false, false
true, false
false, true
#include <stdio.h>
int main() {
int a[] = {1, 2, 3, 4, 5};
int *p = &a[2];
printf("%d", *(p - 1));
return 0;
}
1
2
3
Compilation error
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")
Hello World
Before\nHello World\nAfter
Before\nAfter\nHello World
Error
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);
}
}
1 1
1 2
2 2
0 0
#include <stdio.h>
int main() {
int x = 5;
int y = x++ + ++x;
printf("%d %d", x, y);
return 0;
}
7 12
7 11
6 11
Undefined behavior
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()
Parent
Child
Parent Child
Error
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))
MyClass_v1\n<class 'type'>
MyClass_v1\n<class 'main.Meta'>
Error
None\n<class 'type'>
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");
}
}
}
Result: infinity\nFinally block
Caught exception\nFinally block
Finally block
Program crashes
x = [1, 2, 3]
y = x[:]
y.append(4)
print(len(x), len(y))
3 3
4 4
3 4
4 3
What is the correct way to declare a constant in C?
constant int x = 5;
const int x = 5;
final int x = 5;
readonly int x = 5;
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();
}
}
ABCBC
ADBCBC
DABCBC
DBCBC
Which of the following is the correct syntax to define a function in Python?
function myFunc():
def myFunc():
define myFunc():
func myFunc():
#include <stdio.h>
int main() {
int a = 5, b = 2;
printf("%.2f", (float)a/b);
return 0;
}
2.50
2.00
2
2.5
class A:
def init(self):
print("A")
def new(cls):
print("Creating A")
return super().__new__(cls)
obj = A()
A
Creating A
Creating A\nA
Error
What is the size of an int data type in Java?
2 bytes
4 bytes
8 bytes
Platform dependent
public class Example {
public static void main(String[] args) {
String str = "Hello";
str.concat(" World");
System.out.println(str);
}
}
Hello World
Hello
World
Compilation error
#include <stdio.h>
#define SQUARE(x) x*x
int main() {
int result = SQUARE(3+2);
printf("%d", result);
return 0;
}
25
11
10
9
Java: String str = new String("Hello");
Python: my_list = [1, 2, 3]
C: int *ptr = malloc(sizeof(int));
All three require manual memory deallocation
Java and Python use garbage collection, C requires manual deallocation
Only Java uses garbage collection
All three use automatic garbage collection
3+3
1
5
9
6
