CCS Programming Fundamentals 4 — Questions and Answers
Question 1: What is the purpose of pseudocode in programming?
- To write code that runs faster
- To plan logic in plain language before writing actual code (Correct answer)
- To encrypt source code
- To define database schemas
Correct answer: To plan logic in plain language before writing actual code
Pseudocode is an informal, language-agnostic description of an algorithm used to plan before implementation.
Question 2: Which of the following is an example of a high-level programming language?
- Assembly
- Machine code
- Python (Correct answer)
- Binary
Correct answer: Python
Python is a high-level language that abstracts hardware details, making it easier for humans to read and write.
Question 3: What is the difference between a compiler and an interpreter?
- A compiler runs code line by line; an interpreter translates the whole program at once
- A compiler translates the whole program before execution; an interpreter translates and executes line by line (Correct answer)
- They are the same thing with different names
- A compiler only works with low-level languages
Correct answer: A compiler translates the whole program before execution; an interpreter translates and executes line by line
A compiler converts the entire source code to machine code before running, while an interpreter processes and executes code one line at a time.
Question 4: In programming, what is an 'infinite loop'?
- A loop that runs exactly 1000 times
- A loop whose exit condition is never met, causing it to run forever (Correct answer)
- A loop that skips every other iteration
- A loop nested inside another loop
Correct answer: A loop whose exit condition is never met, causing it to run forever
An infinite loop occurs when the loop's termination condition is never satisfied, causing the program to loop endlessly.
Question 5: What is the role of a 'return' statement in a function?
- To restart the function from the beginning
- To output a value back to the caller and exit the function (Correct answer)
- To declare a local variable
- To import external libraries
Correct answer: To output a value back to the caller and exit the function
A return statement sends a result value back to the code that called the function and ends the function's execution.
Question 6: Which of the following describes the concept of 'inheritance' in object-oriented programming?
- A class hiding its internal data from other classes
- A class acquiring properties and methods from a parent class (Correct answer)
- A single method behaving differently based on context
- Converting one data type to another
Correct answer: A class acquiring properties and methods from a parent class
Inheritance allows a child class to reuse and extend the attributes and behaviors defined in a parent class.
Question 7: What does 'debugging' mean in software development?
- Writing documentation for code
- Finding and fixing errors in a program (Correct answer)
- Optimizing code for speed
- Deploying code to a server
Correct answer: Finding and fixing errors in a program
Debugging is the process of identifying, isolating, and correcting errors (bugs) in a program.
What is the purpose of pseudocode in programming?