Professional Documents
Culture Documents
TECHNICAL EDUCATION
Tech QUIZ
Which of the following is not a primitive
data type in C/C++?
a) int b)
b) float
c) string
d) char
Answer: c) string
In Python, which keyword is used to
define a function?
a) def
b) function
c) define
d) define_function
Answer: a) def
What is the output of the following C code snippet?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x++);
return 0;
}
a) 5
b)6
c) 4
d) Compiler Error
Answer: a) 5
Which data type is used to store a single
character in C/C++?
a) Char
b) Character
c) String
d) chr
Answer: a) char
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 10;
int y = 5;
cout << (x > y ? "x is greater" : "y is greater");
return 0;
}
a) x is greater
b) y is greater
c) 10
d) 5
Answer: a) x is greater
Which symbol is used to indicate the start of
a comment line in Python?
a) //
b) #
c) /
d) /* */
Answer: b) #
What will be the output of the following C code?
#include <stdio.h>
int main() {
int a = 5;
int b = 10;
printf("%d", a & b);
return 0;
}
a) 15
b) 0
c) 5
d) 10
Answer: b) 0
In C++, how is memory allocated
dynamically?
a) malloc()
b) calloc()
c) new
d) All of the above
Answer: d) All of the above
What is the output of the following C code snippet?
#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
printf("%d ", i);
i++;
}
return 0;
}
a) 01234
b) 12345
c) 0123
d) 1234
Answer: a) 0 1 2 3 4
Which of the following is a valid variable name in
Python?
a) my_variable
b) 123variable
c) variable#123
d) $variable
Answer: a) my_variable
What does the "break" statement do in a loop in C/C++?
a) my_list[-1]
b) my_list[last]
c) my_list.end()
d) my_list.last()
Answer: a) my_list[-1]
What is the output of the following Python code?
a)unununium
b)uniumuniumunium
c)ununununium
d)None of the above
Answer: a) unununium
What is the correct way to declare a constant in Python?
a)constant x = 5;
b)define const x = 5;
c)const x = 5;
d)x = 5 (constant)
Answer: c) const x = 5;
In C, what does the "sizeof" operator return?
a) using ==
b) using !=
c) using is
d) using is not
Answer: c) using is
Which of the following is a valid way to declare a
string in C/C++?
a)<stdlib.h>
b) <memory.h>
c) <malloc.h>
d) <alloc.h>
Answer: a) <stdlib.h>
2. What is the result of the expression 5 & 3 in C/C+
+?
a) 1
b) 3
c) 5
d) 0
Answer: a) 1
Which of the following statements is true regarding the
"static" keyword in C/C++?
my_list = [1, 2, 3, 4, 5]
result = [x * 2 for x in my_list if x % 2 == 0]
print(result)
a) [2, 4, 6, 8, 10]
b) [4, 8]
c) [1, 4, 9, 16, 25]
d) [2, 4, 6, 8]
Answer: b) [4, 8]
Which of the following is a correct way to define a function in Python?
a) def my_function:
print("Hello")
b) def my_function():
print("Hello")
c) def my_function
print("Hello")
d) function my_function():
print("Hello")
Answer: b) def my_function():
print("Hello")
In Python, what is the purpose of the __init__ method in a class?
a) It is called when an object is created from the class and allows the
class to initialize attributes.
b) It is called when an object is deleted from the class and allows the
class to clean up resources.
c) It is called when an object is modified and allows the class to
update attributes.
d) It is called when an object is accessed from the class and allows
the class to retrieve attributes.
Answer: a) It is called when an object is created from the class
and allows the class to initialize attributes.
What is the purpose of the super() function in Python?