What does a function help provide?
A Permanent data storage
B Reusable named behavior
C A processor instruction set
D A network connection
Answer: B. Reusable named behavior. Functions package behavior so it can be called by name and reused.
What is recursion?
A A function calls itself
B A loop assigns a value
C An array stores text
D A compiler reads a file
Answer: A. A function calls itself. A recursive function solves a problem by calling itself on smaller cases.
What must recursion include to stop?
A A base case
B A global variable
C A nested class
D A file handle
Answer: A. A base case. The base case ends recursive calls when the simplest case is reached.
What may happen without a reachable base case?
A The compiler sorts variables
B Calls continue until resources fail
C The array becomes immutable
D The loop skips its body
Answer: B. Calls continue until resources fail. Unbounded recursion can exhaust the call stack or other execution resources.
What does a call stack track?
A Sorted array values
B Open network routes
C Compiled source files
D Active function calls
Answer: D. Active function calls. The call stack stores information for active function invocations.
What is an array?
A Single Boolean value
B Function parameter list
C Indexed collection of elements
D Program execution trace
Answer: C. Indexed collection of elements. An array stores multiple elements accessed through indexes.
In a zero based array, what is the first index?
A 1
B 0
C Minus one
D Array length
Answer: B. 0. Zero based indexing starts the first element at index zero.
What is an array bound?
A Valid index range
B Number of source files
C Function's return type
D Loop's update rule
Answer: A. Valid index range. Array bounds define which indexes can be accessed safely.
What is an out of bounds access?
A Reading a valid input
B Calling a declared function
C Using an invalid array index
D Comparing equal values
Answer: C. Using an invalid array index. An out of bounds access uses an index outside the array's valid range.
What is a string commonly used for?
A A single Boolean state
B A loop counter only
C A memory address only
D A sequence of characters
Answer: D. A sequence of characters. A string represents text as a sequence of characters or code units.
Why can string length differ from visible symbols?
A Strings always end in spaces
B Letters have different colors
C Encoding uses multiple units
D A string stores one symbol
Answer: C. Encoding uses multiple units. Some visible symbols, including combined or supplementary characters, use multiple encoded units.
What does a string terminator indicate in C?
A Start of a function
B Maximum array index
C End of character sequence
D Compiler warning level
Answer: C. End of character sequence. C strings conventionally end with a null character.
What is a pointer in languages such as C?
A A loop control keyword
B A text encoding
C A Boolean operator
D Value that stores an address
Answer: D. Value that stores an address. A pointer can refer to a memory location.
What does dereferencing a pointer do?
A Changes the source language
B Accesses the pointed to value
C Counts array elements
D Terminates the program
Answer: B. Accesses the pointed to value. Dereferencing follows a pointer to access the object at its address.
What is a null pointer used to represent?
A The first array element
B No valid object address
C A true Boolean value
D A function return code only
Answer: B. No valid object address. A null pointer does not designate a valid object or memory location.
What is a dangling pointer?
A Valid array pointer
B Pointer passed as an argument
C Pointer with a constant address
D Expired object address
Answer: D. Expired object address. A dangling pointer refers to storage that is no longer a live object.
What is a memory leak?
A Comment syntax issue
B A slow network connection
C Oversized source file
D Unreleased unreachable allocation
Answer: D. Unreleased unreachable allocation. A leak occurs when allocated memory is no longer used but remains unreleased.
What is parameter passing by value?
A Function receives source text
B Function always edits caller variable
C Receives copied value
D Function skips the parameter
Answer: C. Receives copied value. By value passing gives the function its own copy of the argument value.
What may pass by reference allow?
A Function to modify caller's object
B Function to erase source code
C Function to skip execution
D Change function return type
Answer: A. Function to modify caller's object. Reference-style passing can give a function access to the caller's object.
What does a pure function avoid?
A Observable side effects
B Input parameters
C Return values
D Local expressions
Answer: A. Observable side effects. A pure function depends on its inputs and produces no external side effects.
What does a function prototype provide in C?
A Executable machine code
B Array contents
C Function signature declaration
D A debugger breakpoint
Answer: C. Function signature declaration. A prototype tells the compiler a function's name, parameters, and return type.
What is an overload in languages that support it?
A Same name, different signatures
B Function calling itself
C Function without a body
D Variable with multiple values
Answer: A. Same name, different signatures. Overloaded functions share a name but differ in their parameter signatures.
What is a default argument?
A Value returned by every function
B Compiler's default file
C A global loop counter
D Argument value used when omitted
Answer: D. Argument value used when omitted. A default argument supplies a value when a call leaves that parameter unspecified.
What does a lambda commonly represent?
A Small anonymous function
B Named storage device
C Infinite loop
D Array boundary
Answer: A. Small anonymous function. A lambda expression defines a function value, often without a separate name.
What is an exception?
A A normal function parameter
B Signal representing an abnormal condition
C An array dimension
D A compile time constant
Answer: B. Signal representing an abnormal condition. Exceptions report conditions that interrupt normal control flow.