What is a test case?
A A source code comment
B Inputs and expected behavior
C A processor clock cycle
D A variable naming rule
Answer: B. Inputs and expected behavior. A test case pairs conditions or inputs with expected outcomes.
What is unit testing?
A Testing one small program component
B Testing only full network traffic
C Measuring CPU temperature
D Checking spelling in comments
Answer: A. Testing one small program component. Unit tests check small isolated functions or components.
What is an assertion in a test?
A An instruction to repeat forever
B Expected condition
C A source code file type
D A memory allocation method
Answer: B. Expected condition. An assertion checks that a stated condition holds.
What is a breakpoint used for?
A Speed up a loop
B Compile source into bytecode
C Delete a stack frame
D Pause execution during debugging
Answer: D. Pause execution during debugging. A breakpoint pauses a program so its state can be inspected.
What does a debugger's step over do?
A Restarts the whole program
B Deletes the next statement
C Compiles every source file
D Executes call without entry
Answer: D. Executes call without entry. Step over executes a call and pauses at the following statement in the caller.
What is input validation?
A Encrypting every program variable
B Sorting a function's parameters
C Checking data before using it
D Converting source to machine code
Answer: C. Checking data before using it. Validation checks that input meets expected rules and ranges.
Why handle invalid input?
A To make all inputs identical
B To disable error messages
C To skip program documentation
D Avoid unsafe behavior
Answer: D. Avoid unsafe behavior. Checking invalid input helps a program respond safely and predictably.
What is a build process?
A A method for sorting arrays
B A way to declare variables
C Source to executable steps
D A network authentication protocol
Answer: C. Source to executable steps. Building may compile, link, and package program components.
What does a linker commonly combine?
A User input and comments
B Compiled object files and libraries
C Loop counters and conditions
D Pixels and display colors
Answer: B. Compiled object files and libraries. A linker combines object files and libraries into a program or executable.
What is a runtime error?
A Grammar error found before running
B Failure occurring during execution
C A naming convention violation
D A formatting choice in comments
Answer: B. Failure occurring during execution. Runtime errors occur while a program is running.
What does program output represent?
A Results for users
B Only data entered by user
C The source code's indentation
D The compiler's grammar rules
Answer: A. Results for users. Output is information a program sends to a user, file, or another system.
What is standard input commonly used for?
A Writing compiler warnings
B Storing executable files
C Drawing a flowchart
D Receiving program input
Answer: D. Receiving program input. Standard input is a conventional stream for input data.
What is standard output commonly used for?
A Writing normal program results
B Receiving keyboard input only
C Storing a processor register
D Declaring a function type
Answer: A. Writing normal program results. Standard output is a conventional stream for normal program output.
What is a library in programming?
A A hardware power source
B A loop termination condition
C A variable scope region
D Reusable code collection
Answer: D. Reusable code collection. A library provides reusable functions, types, or other program components.
What is an API?
A Defined interface for software interaction
B An array index type
C A processor's arithmetic unit
D A source code comment
Answer: A. Defined interface for software interaction. An API specifies how software components can request services from each other.
What is version control used for?
A Executing source code faster
B Validating every runtime input
C Tracking and managing code changes
D Converting characters to numbers
Answer: C. Tracking and managing code changes. Version control records changes and supports collaboration and recovery.
What does a code review examine?
A Proposed code changes
B Only the user interface colors
C Processor temperature readings
D The disk's physical sectors
Answer: A. Proposed code changes. A review checks proposed changes for correctness, clarity, and maintainability.
What is a naming convention?
A A method of sorting files
B Consistent rule for identifier names
C A compiler optimization pass
D A fixed processor opcode
Answer: B. Consistent rule for identifier names. Naming conventions improve readability through consistent identifier styles.
What does Big O notation describe?
A The exact program output
B A programming language syntax
C A variable's storage address
D Resource growth with input
Answer: D. Resource growth with input. Big O characterizes asymptotic growth in time or space as input grows.
What is constant time complexity?
A Fixed work as input grows
B Work doubles with every item
C Work equals input squared
D Memory always equals input size
Answer: A. Fixed work as input grows. Constant time indicates that operation count stays bounded as input size increases.
What does linear search do?
A Sorts values by halves
B Hashes every key to memory
C Checks items sequentially
D Builds a binary tree
Answer: C. Checks items sequentially. Linear search examines elements one by one until a match or the end.
What precondition enables binary search?
A Data contains no duplicates
B Data is stored as text
C Data is sorted
D Data has exactly two items
Answer: C. Data is sorted. Binary search relies on sorted data to discard half the remaining range each step.
Why use meaningful variable names?
A Clarify code intent
B Reduce source file bytes
C To prevent compiler optimization
D To replace input validation
Answer: A. Clarify code intent. Names that reflect purpose make code easier to read and maintain.
What is refactoring?
A Adding a new user feature
B Removing all test cases
C Improving structure without changing behavior
D Changing input to output
Answer: C. Improving structure without changing behavior. Refactoring restructures code while preserving its externally observable behavior.
What does maintainability describe?
A Maximum processor clock speed
B Ease of changing software
C Number of program variables
D Size of an executable only
Answer: B. Ease of changing software. Maintainable software is easier to fix, extend, and understand over time.