Fundamentals of Programming MCQs (Part-1)

What is a variable in programming?

A Data type
B Function
C Memory
D Placeholder

Which of the following is a correct way to declare a variable in Python?

A declare x = 10
B x = 10
C int x = 10
D int x:10

What is the purpose of a loop in programming?

A To create functions
B To skip sections of code
C To repeat code
D To execute code once

Which operator is used for equality comparison in C?

A !=
B ==
C =
D ===

In Python, how do you define a function?

A def function_name()
B create function_name()
C function = def()
D function function_name()

What does an exception in programming represent?

A A variable type
B A program error
C A data structure
D A type of loop

What is the purpose of a constructor in Object-Oriented Programming (OOP)?

A To create methods
B To define a class
C To declare variables
D To initialize an object

Which of the following is a valid identifier in Java?

A variable_1
B variable#
C 2variable
D @variable

Which type of memory allocation does malloc perform in C?

A Heap allocation
B Dynamic allocation
C Static allocation
D Stack allocation

What does the return statement do in a function?

A Returns the function name
B Ends the program
C Starts the function
D Sends a value from the function

What is the output of print(10 // 3) in Python?

A 0
B 3
C 10
D 3.33

Which of these data types is used to store decimal numbers in C?

A bool
B int
C char
D float

What does sizeof() do in C?

A Returns the data type
B Returns the memory address
C Returns the size of a data type
D Returns the value of a variable

Which of the following is NOT a feature of Object-Oriented Programming?

A Encapsulation
B Compilation
C Inheritance
D Polymorphism

Which data structure is used to store key-value pairs?

A Dictionary
B Queue
C Array
D List