Fundamentals of Programming MCQs (Part-14)

What does the if statement do in programming?

A Tests a condition
B Defines a function
C Loops through code
D Breaks the loop

In C, which data type is used to represent a single character?

A string
B char
C int
D float

Which of the following is used to declare a function in C?

A function_name()
B def
C function
D void

What is the purpose of break in loops?

A Restarts the loop
B Exits the loop
C Skips the iteration
D Continues the loop

In Python, how do you check if a variable is of a specific type?

A type()
B instance()
C check()
D is()

Which operator is used to perform division in Python?

A %
B //
C *
D /

In Java, which of the following is used to handle multiple exceptions in a try block?

A throws
B catch
C throw
D finally

What is a pointer in C?

A A memory address holder
B A variable
C A reference
D A data type

What does the sizeof() operator do in C?

A Returns data type
B Allocates memory
C Returns size in bytes
D Returns memory address

Which of these is a valid array declaration in C?

A int[] arr = {}
B int arr[10];
C array int[10];
D int arr[]

In Java, what does the new keyword do?

A Initializes a method
B Creates a new class
C Creates a function
D Allocates memory for an object

Which of the following is used to define a string in Python?

A ()
B “”
C string()
D []

In C, which of the following functions is used to open a file?

A fileopen()
B open()
C file()
D fopen()

What is the primary purpose of the main() method in Java?

A Initialize variables
B Handle exceptions
C Serve as the entry point
D Define a class

In Python, which of the following is used to terminate a loop early?

A break
B return
C continue
D exit