AEE/Chapter 4/Read MCQs
๐Ÿ“– Back to Study Notes
4

Chapter 4 ยท MCQ Read Mode

Computer Programming

AEEE04ยท60 Total MCQs
Question 1 of 60Introduction to Programming

Which of the following is NOT a token in a C program?

AKeyword
BIdentifier
CConstant
DComment block
Answer is hidden
Question 2 of 60Introduction to Programming

The smallest individual unit of a program is called a:

AStatement
BToken
CFunction
DHeader file
Answer is hidden
Question 3 of 60Introduction to Programming

Which data type is used to store decimal (floating-point) numbers?

Aint
Bchar
Cfloat
Dvoid
Answer is hidden
Question 4 of 60Introduction to Programming

A named memory location used to store a value that can change is called a:

AConstant
BVariable
CKeyword
DOperator
Answer is hidden
Question 5 of 60Introduction to Programming

In C, the format specifier used to print an integer with printf() is:

A%f
B%d
C%c
D%s
Answer is hidden
Question 6 of 60Introduction to Programming

Which operator is used for logical AND in C?

A&
B&&
C|
D||
Answer is hidden
Question 7 of 60Introduction to Programming

Structured programming primarily organizes a program around:

AObjects and classes
BFunctions/procedures operating on data
COnly global variables
DMachine code directly
Answer is hidden
Question 8 of 60Introduction to Programming

In object-oriented programming, data and functions are bound together into a single unit called a(n):

AArray
BObject
CPointer
DLoop
Answer is hidden
Question 9 of 60Introduction to Programming

In a flowchart, a diamond shape represents:

AStart/End
BProcess
CDecision
DInput/Output
Answer is hidden
Question 10 of 60Introduction to Programming

An algorithm is best described as:

AA programming language
BA step-by-step procedure to solve a problem
CA type of variable
DA compiler error
Answer is hidden
Question 11 of 60Control Statements

Which statement executes one of several blocks based on the value of a single variable?

Aif
Bswitch
Cwhile
Dfor
Answer is hidden
Question 12 of 60Control Statements

A for loop's three components, in order, are:

ACondition; Initialization; Increment
BInitialization; Condition; Increment
CIncrement; Condition; Initialization
DCondition only
Answer is hidden
Question 13 of 60Control Statements

Which loop is guaranteed to execute at least once, regardless of the condition?

Afor loop
Bwhile loop
Cdo-while loop
DNone of these
Answer is hidden
Question 14 of 60Control Statements

The while loop is best described as:

AExit-controlled
BEntry-controlled
CNever checking a condition
DAlways infinite
Answer is hidden
Question 15 of 60Control Statements

The break statement, when used inside a loop, causes:

AThe loop to restart
BImmediate exit from the loop
CThe next iteration to be skipped
DA compile error
Answer is hidden
Question 16 of 60Control Statements

The continue statement causes:

AThe loop to terminate completely
BThe current iteration to skip its remaining code and jump to the next iteration
CThe program to exit
DNothing
Answer is hidden
Question 17 of 60Control Statements

In a switch statement, the default case executes when:

AThe first case matches
BNo other case matches
CEvery case matches
DThe switch statement has an error
Answer is hidden
Question 18 of 60Control Statements

Nested if-else statements are used to:

ARepeat a block indefinitely
BTest multiple conditions in sequence
CDeclare multiple variables
DDefine a function
Answer is hidden
Question 19 of 60Control Statements

The goto statement performs:

AA conditional loop
BAn unconditional jump to a labeled statement
CA function call
DA memory allocation
Answer is hidden
Question 20 of 60Control Statements

Which loop structure is typically preferred when the number of iterations is known in advance?

Ado-while
Bfor
Cwhile
DNone of these
Answer is hidden
Question 21 of 60Functions

A function prototype specifies:

AThe complete function body
BThe function's return type, name, and parameter types (before its use)
COnly the function name
DThe value returned at runtime
Answer is hidden
Question 22 of 60Functions

In call by value, changes made to a parameter inside the function:

AAffect the original argument
BDo not affect the original argument
CCause a compile error
DAlways crash the program
Answer is hidden
Question 23 of 60Functions

In call by reference, the function receives:

AA copy of the value
BThe address of the argument
CNothing
DOnly the data type
Answer is hidden
Question 24 of 60Functions

A recursive function is one that:

ANever terminates
BCalls itself to solve smaller instances of the same problem
CCannot have parameters
DIs always faster than an iterative solution
Answer is hidden
Question 25 of 60Functions

Every recursive function must have a:

ALoop statement
BBase case to terminate recursion
CPointer argument
DReturn type of void
Answer is hidden
Question 26 of 60Functions

The main advantage of using functions in a program is:

AIncreased code duplication
BModularity and code reusability
CAlways slower execution
DRemoval of all variables
Answer is hidden
Question 27 of 60Functions

A function that does not return any value should have a return type of:

Aint
Bfloat
Cvoid
Dchar
Answer is hidden
Question 28 of 60Functions

Passing an array to a function in C effectively passes:

AA full copy of the array
BA pointer to the array's first element
CNothing
DOnly the array's size
Answer is hidden
Question 29 of 60Functions

Local variables declared inside a function are:

AAccessible from anywhere in the program
BAccessible only within that function
CAutomatically global
DStored permanently
Answer is hidden
Question 30 of 60Functions

Recursive functions typically use more:

AGlobal variables
BStack memory, due to repeated function calls
CHeap memory only
DNone of the above
Answer is hidden
Question 31 of 60Pointers & Data Files

A pointer is a variable that stores:

AA character value
BThe address of another variable
CA floating-point number only
DA function name only
Answer is hidden
Question 32 of 60Pointers & Data Files

The & operator, when applied to a variable, returns its:

AValue
BAddress
CData type
DSize
Answer is hidden
Question 33 of 60Pointers & Data Files

The * operator, when applied to a pointer, is used to:

AMultiply two pointers
BDereference the pointer (access the value at that address)
CDeclare an integer
DDelete the pointer
Answer is hidden
Question 34 of 60Pointers & Data Files

Incrementing a pointer (ptr++) moves it forward by:

AExactly 1 byte always
Bsizeof(the pointed-to data type) bytes
CA random amount
D4 bytes always regardless of type
Answer is hidden
Question 35 of 60Pointers & Data Files

In C, an array name used in an expression generally decays to a:

AStructure
BPointer to its first element
CConstant integer
DFunction
Answer is hidden
Question 36 of 60Pointers & Data Files

Which function is used in C to dynamically allocate memory at runtime?

Afree()
Bmalloc()
Cprintf()
Dscanf()
Answer is hidden
Question 37 of 60Pointers & Data Files

The free() function in C is used to:

AAllocate new memory
BRelease previously allocated dynamic memory
CDeclare a pointer
DInitialize a variable
Answer is hidden
Question 38 of 60Pointers & Data Files

arr[i] in C is equivalent to which pointer expression?

A*(arr+i)
B&arr+i
Carr*i
D*arr+i
Answer is hidden
Question 39 of 60Pointers & Data Files

In C++, dynamic memory is typically allocated using the:

Amalloc keyword
Bnew keyword
Calloc keyword
Dcreate keyword
Answer is hidden
Question 40 of 60Pointers & Data Files

Subtracting two pointers of the same type gives:

AThe byte difference always
BThe number of elements between them
CAn error always
DA boolean value
Answer is hidden
Question 41 of 60Arrays & Structures

An array is best described as:

AA collection of different data types in one variable
BA collection of elements of the same data type stored contiguously
CA pointer to a function
DA single variable only
Answer is hidden
Question 42 of 60Arrays & Structures

When an array is passed to a function in C, it is passed:

ABy value, as a full copy
BEffectively by reference, via a pointer
CNot allowed at all
DOnly as a string
Answer is hidden
Question 43 of 60Arrays & Structures

A two-dimensional array can be thought of as:

AAn array of pointers only
BAn array of arrays (rows and columns)
CA single scalar value
DA linked list
Answer is hidden
Question 44 of 60Arrays & Structures

A structure (struct) in C is used to:

AStore only one data type
BGroup variables of different data types under one name
CReplace all arrays
DPerform arithmetic operations
Answer is hidden
Question 45 of 60Arrays & Structures

To access a member of a structure through a pointer to that structure, which operator is used?

A. (dot)
B-> (arrow)
C&
D*
Answer is hidden
Question 46 of 60Arrays & Structures

An array of structures is used to:

AStore multiple records, each with the same structure layout
BStore only integers
CReplace pointers
DDefine a new data type from scratch
Answer is hidden
Question 47 of 60Arrays & Structures

Structure members can be initialized:

AOnly after the program has fully run
BAt the time of declaration, using an initializer list
CNever
DOnly inside a loop
Answer is hidden
Question 48 of 60Arrays & Structures

Compared to an array, a structure can:

AOnly hold elements of the same type
BHold elements of different data types together
CNot be passed to a function
DNot have a pointer
Answer is hidden
Question 49 of 60Arrays & Structures

In C, accessing structure members directly (not via a pointer) uses which operator?

A->
B. (dot)
C&
D*
Answer is hidden
Question 50 of 60Arrays & Structures

Multidimensional arrays are commonly used to represent:

ASingle scalar values
BMatrices and tables of data
COnly strings
DFunction prototypes
Answer is hidden
Question 51 of 60Features of Object-Oriented Programming

In object-oriented programming, a class is best described as:

AAn instance of an object
BA blueprint/template that defines data members and member functions
CA built-in data type
DA loop construct
Answer is hidden
Question 52 of 60Features of Object-Oriented Programming

An object is:

AA blueprint for a class
BAn instance of a class
CA function prototype
DA pointer only
Answer is hidden
Question 53 of 60Features of Object-Oriented Programming

An inline function is primarily used to:

AIncrease code size without benefit
BAvoid function-call overhead for small, frequently used functions
CEnable recursion only
DStore static data
Answer is hidden
Question 54 of 60Features of Object-Oriented Programming

Function overloading allows:

AMultiple functions with the same name but different parameter lists
BOnly one function per class
CFunctions to call themselves
DGlobal variables to be redefined
Answer is hidden
Question 55 of 60Features of Object-Oriented Programming

A private member function of a class can be accessed:

AFrom anywhere in the program
BOnly from within the class's own member functions (by default)
COnly from derived classes
DOnly from the main() function
Answer is hidden
Question 56 of 60Features of Object-Oriented Programming

Static data members of a class are:

AUnique to each object created
BShared among all objects of the class
CNever initialized
DAlways private
Answer is hidden
Question 57 of 60Features of Object-Oriented Programming

A static member function can be called:

AOnly through an object instance
BWithout creating an object of the class
COnly inside another static function
DNever
Answer is hidden
Question 58 of 60Features of Object-Oriented Programming

Operator overloading allows a programmer to:

ACreate entirely new operators
BRedefine the behaviour of existing operators for user-defined types
CRemove operators from the language
DOnly overload the assignment operator
Answer is hidden
Question 59 of 60Features of Object-Oriented Programming

Inheritance in OOP allows a derived class to:

ADelete the base class
BAcquire properties and behaviours of a base class, promoting code reuse
CNever access base class members
DReplace the base class entirely
Answer is hidden
Question 60 of 60Features of Object-Oriented Programming

Polymorphism in OOP refers to the ability of:

AA variable to change its data type at will
BA function or object to take multiple forms (e.g., through overloading or overriding)
CA program to run without compiling
DArrays to resize dynamically
Answer is hidden
โ† PREVIOUS CHAPTERCh 3: Digital Logic and MicroprocessorNEXT CHAPTER โ†’Ch 5: Measurement, Instrumentation and Control