0% found this document useful (0 votes)
24 views10 pages

Glitch-Hunt Programming Quiz Prelims

The document contains two sets of quiz questions focused on programming concepts and debugging in languages like Python, Java, and C. Each set includes multiple-choice questions covering exception handling, output predictions, and error identification. An answer key for the prelims is also provided at the end.

Uploaded by

S. Kiran Barade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views10 pages

Glitch-Hunt Programming Quiz Prelims

The document contains two sets of quiz questions focused on programming concepts and debugging in languages like Python, Java, and C. Each set includes multiple-choice questions covering exception handling, output predictions, and error identification. An answer key for the prelims is also provided at the end.

Uploaded by

S. Kiran Barade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Glitch-Hunt

Quiz Prelims
SET 1
Let’s Get Rid of Bugs
____________________________________________________________________________

1. Which of the following is not a valid way to handle exceptions in Python?

a) try...except c) try...except...catch
b) try...except...finally d) try...except...else

2. What will be the output of the following code :


print(type(type(int)))
a) type \'int\' c) Error
b) type \'type\' d) 0

3. Which programming language is known as What is the output of the following program?
set1 = {1, 2, 3}
set2 = [Link]()
[Link](4)
print(set1)

a) {1, 2, 3,4} c) error


b) {1, 2, 3} d) invalid syntax
4. What is the problem in the following Java program?

java
public class Test {
public static void main(String[] args) {
Object obj = null;
[Link]([Link]());
}
}
a) No issue, it will print null c) Compilation error
b) NullPointerException at runtime d) StackOverflowError

5. What does the [Link](1000); statement do in debugging?


a) Stops the thread execution for 1 c) Pauses execution indefinitely
second d) Causes a compilation error
b) Stops the entire program for 1
second

6. What is the problem in the following Java program?*


java
public class Test {
public static void main(String[] args) {
Object obj = null;
[Link]([Link]());
}
}
a) No issue, it will print null c) Compilation error
b) NullPointerException at runtime d) StackOverflowError
7. What will happen if you execute the following C code?

#include <stdio.h>
int main() {
int x;
printf("%d", x);
return 0;
}
a) Compilation error c) 0
b) Undefined behavior d) Prints garbage value
[Link] does the *valgrind* tool help with in C debugging?
a) Detecting memory leaks c) Compiling C programs
b) Optimizing code execution d) Syntax checking

[Link] will happen if a *NULL pointer* is dereferenced in C?


a) The program will execute normally c) It will print a NULL value
b) It will cause a segmentation fault d) It will return 0

[Link] will be the output of the following Python code?


def foo(x, y=2, z=3):
return x + y + z
print(foo(1, z=5))
a) 6 c) 8
b) 7 d) 10
11. What is the output of the following code?
x = (1, 2, 3)
x[1] = 4a) (1, 4, 3)
b) (1, 2, 4)
c) (4, 2, 3)
d) error

12. What does *segmentation fault (core dumped)* indicate in C?


a) Compiler error c) Successful program execution
b) Memory access violation d) Syntax error

[Link] does the term *breakpoint* refer to in Java debugging?


a) A point where execution speeds up
b) A pause point in code execution for inspection
c) A place where the JVM stops working
d) A compiler error
[Link] is the output of the following program?
tup = (1, 2, 3, 4)
[Link]( (5, 6, 7) )
print(len(tup))
a) 4 c) 7
b) 3 d) error

15. What is the output of the following program?


set1 = {1, 2, 3} print(set1)
set2 = [Link]()
[Link](4)
a) {1, 2, 3, 4} c) 0
b) {1, 2, 3} d) error
Glitch-Hunt
Quiz Prelims
SET 2
Let’s Get Rid of Bugs
____________________________________________________________________________

1. Which of the following is not a valid way to handle exceptions in Python?

a) try...except c) try...except...catch
b) try...except...finally d) try...except...else

2. What will be the output of the following code :


print(type(type(int)))
a) type \'int\' c) Error
b) type \'type\' d) 0

3. Which programming language is known as What is the output of the following program?
set1 = {1, 2, 3}
set2 = [Link]()
[Link](4)
print(set1)

a) {1, 2, 3,4} c) error


b) {1, 2, 3} d) invalid syntax
4. What is the problem in the following Java program?

java
public class Test {
public static void main(String[] args) {
Object obj = null;
[Link]([Link]());
}
}
a) No issue, it will print null c) Compilation error
b) NullPointerException at runtime d) StackOverflowError

5. What does the [Link](1000); statement do in debugging?


a) Stops the thread execution for 1 c) Pauses execution indefinitely
second d) Causes a compilation error
b) Stops the entire program for 1
second

6. What is the problem in the following Java program?*


java
public class Test {
public static void main(String[] args) {
Object obj = null;
[Link]([Link]());
}
}
a) No issue, it will print null c) Compilation error
b) NullPointerException at runtime d) StackOverflowError
7. What will happen if you execute the following C code?

#include <stdio.h>
int main() {
int x;
printf("%d", x);
return 0;
}
a) Compilation error c) 0
b) Undefined behavior d) Prints garbage value
[Link] does the *valgrind* tool help with in C debugging?
a) Detecting memory leaks c) Compiling C programs
b) Optimizing code execution d) Syntax checking

[Link] will happen if a *NULL pointer* is dereferenced in C?


a) The program will execute normally c) It will print a NULL value
b) It will cause a segmentation fault d) It will return 0

[Link] will be the output of the following Python code?


def foo(x, y=2, z=3):
return x + y + z
print(foo(1, z=5))
a) 6 c) 8
b) 7 d) 10
11. What is the output of the following code?
x = (1, 2, 3)
x[1] = 4a) (1, 4, 3)
b) (1, 2, 4)
c) (4, 2, 3)
d) error

12. What does *segmentation fault (core dumped)* indicate in C?


a) Compiler error c) Successful program execution
b) Memory access violation d) Syntax error

[Link] does the term *breakpoint* refer to in Java debugging?


a) A point where execution speeds up
b) A pause point in code execution for inspection
c) A place where the JVM stops working
d) A compiler error
[Link] is the output of the following program?
tup = (1, 2, 3, 4)
[Link]( (5, 6, 7) )
print(len(tup))
a) 4 c) 7
b) 3 d) error

15. What is the output of the following program?


set1 = {1, 2, 3} print(set1)
set2 = [Link]()
[Link](4)
a) {1, 2, 3, 4}
b) {1, 2, 3}
c) 0
d) error
Answer key for prelims
SET 1 SET 2 SET 3
1. a) Dry Ice 1. c) HTTPS 1. b) Pragyan
2. d) Assembly 2. c) C 2. c) C
3. a) Hot water 3. b) Sodium carbonate 3. d) Violet
4. b) Pragyan 4. b) Bluetooth 4. b) Sodium carbonate
5. d) Bengaluru 5. b) Water 5. b) Light
6. b) Light 6. c) Verghese Kurien Amplification by
Amplification by 7. a) IIT Madras Stimulated Emission
Stimulated Emission 8. d) Bengaluru of Radiation
of Radiation 9. b) Radioactivity 6. a) Dry Ice
7. c) Verghese Kurien 10.a) Dry Ice 7. b) Chemical Energy
8. b) Bluetooth 11.b) Smart Grid 8. c) HTTPS
9. b) Water 12.b) Refraction 9. c) Verghese Kurien
10.b) Chemical Energy 13.b) Light 10.a) Hot water
11.c) HTTPS Amplification by 11.a) IIT Madras
12.b) Radioactivity Stimulated Emission 12.b) Refraction
13.d) Violet of Radiation 13.a) Newton’s First
14.b) Smart Grid 14.d) Violet Law
15.b) Refraction 15.a) Newton’s First 14.b) Bluetooth
16.a) IIT Madras Law 15.b) Smart Grid
17.a) Newton’s First 16.b) Pragyan 16.c) Sir C.V. Raman
Law 17.c) Sir C.V. Raman 17.d) Bengaluru
18.c) Sir C.V. Raman 18.b) Chemical Energy 18.b) Water
19.a) International 19.a) Hot water 19.b) Radioactivity
Business Machines 20.a) International 20.a) International
20.b) Sodium carbonate Business Machines Business Machine

You might also like