Programming Fundamentals MCQs (Set-2)

Which operator commonly tests equality?

A Assignment operator
B Increment operator
C Concatenation operator
D Equality comparison operator

What does assignment usually do?

A Compares two expressions
B Repeats a statement
C Stores value in variable
D Declares a class

What is the result of 7 mod 3?

A 2
B 3
C 1
D 4

What does logical AND return true for?

A Either condition is true
B Both conditions are false
C Neither value is Boolean
D Both conditions are true

What does logical OR return true for?

A At least one condition true
B Only both conditions false
C Only equal numbers
D No conditions at all

What does logical NOT do?

A Adds two numbers
B Copies a string
C Ends a program
D Reverses a Boolean value

Which structure selects between alternatives?

A Sequence declaration
B Conditional statement
C Comment block
D Data type cast

What is the purpose of an if statement?

A Repeat code forever
B Declare a constant
C Run code when condition holds
D Define a file path

What does an else branch handle?

A The alternative condition path
B The loop counter
C A function return type
D A memory address

Which loop checks a condition before each iteration?

A Pretest loop
B Posttest loop
C Infinite loop only
D Recursive call

Which loop guarantees one body execution?

A Pretest loop
B Conditional expression
C Posttest loop
D Event handler

What commonly controls a counted loop?

A Input output exception
B Initialization condition update
C Class object method
D Array string pointer

What is an off by one error?

A Wrong loop boundary
B Variable has wrong type
C Compiler cannot parse a token
D Program cannot open a file

What does break commonly do inside a loop?

A Skips one iteration
B Restarts the program
C Exits the nearest loop
D Declares a new variable

What does continue commonly do inside a loop?

A Skips to next iteration
B Exits every function
C Clears the loop condition
D Returns a stored value

What is a nested loop?

A A loop inside another loop
B A loop without condition
C A function inside a variable
D A comment inside code

What does operator precedence determine?

A How values are stored
B Where functions are declared
C Which files compile first
D Order operators are evaluated

Why use parentheses in an expression?

A To allocate array memory
B To make grouping explicit
C To end a function
D To declare a Boolean

What does short circuit evaluation mean?

A All operators run twice
B Expressions always run backward
C Values are converted to text
D Skip unneeded logic

What does a function parameter represent?

A Value printed by a loop
B Global memory block
C Compiler output file
D Input name in function definition

What is an argument in a function call?

A Function's source file
B Returned type declaration
C Value supplied to a parameter
D Loop's final condition

What does return usually do?

A Repeats the current loop
B Sends a result to caller
C Creates a new module
D Reads keyboard input

What is a function's return type?

A Type of its source file
B Type of value it produces
C Number of parameters only
D Scope of its variables

What is a local variable?

A Block scoped variable
B Variable shared by every program
C A fixed processor register
D Persistent file value

What is a global variable?

A File scoped variable
B Variable declared outside local scopes
C Function's argument
D Temporary input character