Fundamentals of Programming MCQs (Part-4)

What is the result of 5 + 3 * 2 in C?

A 10
B 16
C 11
D 8

What type of loop guarantees at least one execution in C?

A if
B while
C for
D do-while

Which keyword is used to define a function in Python?

A func
B def
C define
D function

Which operator in Java is used for division?

A /
B *
C //
D &

Which type of error occurs during runtime?

A Compilation error
B Runtime error
C Logical error
D Syntax error

What does the && operator do in C?

A Compares values
B Assigns values
C Checks equality
D Logical AND

Which of these statements is used to exit a loop in Python?

A stop
B exit
C break
D continue

Which data type in Java is used to store boolean values?

A char
B boolean
C int
D bool

What is the output of print(“Hello”[1]) in Python?

A l
B H
C o
D e

Which of these keywords is used for creating a constant in Java?

A final
B immutable
C constant
D static

What does sizeof() return in C?

A Length of array
B Size of data
C Memory address
D Size of variable

Which data type is used for decimals in Java?

A float
B int
C char
D double

What is the correct syntax to create a method in Java?

A function methodName()
B void methodName()
C def methodName()
D method methodName()

Which of these is used to handle exceptions in Python?

A try-finally
B try-except
C handle-error
D try-catch

What is the correct way to declare an integer array in C?

A int arr[]
B arr int[]
C int[] arr
D arr int[10]