Fundamentals of Programming MCQs (Part-2)

Which keyword is used to create a class in Python?

A object
B create
C define
D class

What is the default return type of a function in C if no type is specified?

A float
B void
C int
D char

Which data type in Java is used for storing a single character?

A char
B string
C int
D boolean

Which of the following is used to handle errors in Java?

A abort
B exception
C try-catch
D error

What is the purpose of the break statement in a loop?

A Skip the iteration
B End the loop
C Exit the function
D Continue the loop

Which of the following is a valid way to define a list in Python?

A list = ()
B list = []
C list = <>
D list = {}

What is the primary purpose of the malloc() function in C?

A Free memory
B Perform arithmetic
C Allocate dynamic memory
D Initialize a variable

Which of these is used for conditional statements in C?

A for
B if-else
C do-while
D while

In Java, how do you handle multiple exceptions in a single catch block?

A Use a comma
B Use if
C Use || operator
D Use | operator

What is the purpose of a destructor in OOP?

A To destroy objects
B To modify objects
C To create objects
D To initialize objects

Which of these is used to store key-value pairs in Python?

A Set
B Dictionary
C List
D Tuple

Which operator is used to assign a value to a variable in Java?

A +
B :=
C ==
D =

What does the continue statement do in a loop?

A Exits the program
B Skips the current iteration
C Ends the loop
D Pauses the loop

What is the purpose of a pointer in C?

A Point to memory location
B Define a variable
C Declare a constant
D Store a value

Which of the following is the correct way to declare an array in C?

A arr = int[3]{1, 2, 3}
B int arr[] = {1, 2, 3}
C array int[] = {1, 2, 3}
D int[] arr = {1, 2, 3}