ICAS Programming and Digital Systems 2 — Questions and Answers
Question 1: Which data structure uses a Last-In, First-Out (LIFO) principle?
- Queue
- Stack (Correct answer)
- Linked List
- Array
Correct answer: Stack
A stack operates on LIFO, meaning the last element added is the first one removed.
Question 2: What does the term 'bug' mean in programming?
- A virus attacking the code
- An error or flaw in the program (Correct answer)
- A missing semicolon only
- A slow-running loop
Correct answer: An error or flaw in the program
A bug is any error or unintended behavior in a program that causes it to produce incorrect results.
Question 3: In binary, what is the value of 1011?
- 9
- 10
- 11 (Correct answer)
- 13
Correct answer: 11
1011 in binary = 8 + 0 + 2 + 1 = 11 in decimal.
Question 4: Which type of loop is guaranteed to execute its body at least once?
- for loop
- while loop
- do-while loop (Correct answer)
- foreach loop
Correct answer: do-while loop
A do-while loop checks its condition after executing the body, ensuring at least one execution.
Question 5: What is an algorithm?
- A programming language
- A type of computer hardware
- A step-by-step set of instructions to solve a problem (Correct answer)
- A data storage format
Correct answer: A step-by-step set of instructions to solve a problem
An algorithm is a finite, ordered set of instructions designed to solve a specific problem or perform a task.
Question 6: Which of the following best describes 'pseudocode'?
- Code written in Python
- Fake code used to hack systems
- An informal description of a program's logic (Correct answer)
- Machine-readable binary instructions
Correct answer: An informal description of a program's logic
Pseudocode is a plain-language description of programming logic, not tied to any specific language syntax.
Question 7: What does a compiler do?
- Runs code line by line
- Translates high-level code into machine code (Correct answer)
- Stores data in memory
- Connects to the internet
Correct answer: Translates high-level code into machine code
A compiler translates the entire source code written in a high-level language into machine-readable code before execution.
Which data structure uses a Last-In, First-Out (LIFO) principle?