Fundamentals of Programming Practice Questions

A-Levels · A-Level Computer Science · 149 free MCQs with instant results and detailed explanations.

149
Total
46
Easy
73
Medium
30
Hard

Start Practicing Fundamentals of Programming

Take a timed quiz or customize your practice session

Quick Quiz (10 Qs) → Mock Test (25 Qs) ⚙ Customize

Sample Questions from Fundamentals of Programming

Here are 10 sample questions. Start a quiz to get randomized questions with scoring.

Q1
Easy
Which of the following is a valid way to declare a variable in Python?
A. var x = 10
B. let x: int = 10
C. x = 10
D. define x as 10
Show Answer & Explanation
Correct Answer: C
In Python, a variable is declared simply by assigning a value to it without any specific keyword, making option C the correct choice.
Q2
Easy
What will be the output of the following pseudo-code: if (5 > 3) then print("True") else print("False")
A. True
B. False
C. Error
D. None of the above
Show Answer & Explanation
Correct Answer: A
The condition 5 > 3 is true, so the output will be 'True' as specified in the pseudo-code.
Q3
Easy
Which of the following data types is best suited for storing a single character in Java?
A. String
B. Character
C. int
D. boolean
Show Answer & Explanation
Correct Answer: B
In Java, the 'char' data type is specifically used to store single characters, making option B the best choice.
Q4
Medium
What is the primary purpose of an algorithm in programming?
A. To define the structure of a program
B. To specify the step-by-step solution to a problem
C. To write code in a specific programming language
D. To debug errors in a program
Show Answer & Explanation
Correct Answer: B
An algorithm provides a clear step-by-step method to solve a specific problem, which is fundamental in programming.
Q5
Medium
Which of the following data types can store decimal numbers in most programming languages?
A. Integer
B. String
C. Float
D. Boolean
Show Answer & Explanation
Correct Answer: C
The Float data type is specifically designed to store decimal numbers and is widely used for such purposes in programming.
Q6
Medium
If a loop runs 10 times and each iteration contains a function call that takes 2 seconds to execute, what is the total time taken by the loop?
A. 10 seconds
B. 20 seconds
C. 30 seconds
D. 40 seconds
Show Answer & Explanation
Correct Answer: B
If the loop runs 10 times and each function call takes 2 seconds, the total time is 10 * 2 = 20 seconds.
Q7
Medium
What does the term 'recursion' refer to in programming?
A. The process of repeating a function until a condition is met
B. A method to organize code for better readability
C. Using multiple threads to execute code simultaneously
D. A way to store data in memory
Show Answer & Explanation
Correct Answer: A
Recursion is when a function calls itself to solve a smaller instance of a problem, repeating until a base condition is met.
Q8
Hard
In the context of programming languages, what does 'polymorphism' allow a function to do?
A. Execute multiple operations with the same name for different data types.
B. Automatically optimize code for performance during compilation.
C. Reduce the amount of memory used by a program's variables.
D. Ensure that all functions in a program can return multiple values.
Show Answer & Explanation
Correct Answer: A
'Polymorphism' allows a function to execute multiple operations using the same name but adapted for different data types, enhancing flexibility and reusability in programming.
Q9
Hard
Consider a recursive function designed to calculate the factorial of a number n. If the function is called with n = 5, how many recursive calls are made before reaching the base case?
A. 4
B. 5
C. 6
D. 1
Show Answer & Explanation
Correct Answer: B
For n = 5, the recursive calls are 5! calls 4!, 4! calls 3!, 3! calls 2!, and 2! calls 1!. This means a total of 5 recursive calls are made before reaching the base case (1!).
Q10
Hard
Which of the following sorting algorithms has the best average-case time complexity?
A. Quick Sort
B. Bubble Sort
C. Insertion Sort
D. Selection Sort
Show Answer & Explanation
Correct Answer: A
Quick Sort has an average-case time complexity of O(n log n), which is better than the O(n^2) average case of Bubble, Insertion, and Selection Sort. This efficiency makes it the preferred choice for sorting in most applications.

Showing 10 of 149 questions. Start a quiz to practice all questions with scoring and timer.

Practice All 149 Questions →

Fundamentals of Programming โ€” A-Levels A-Level Computer Science Practice Questions Online

This page contains 149 practice MCQs for the chapter Fundamentals of Programming in A-Levels A-Level Computer Science. The questions are organized by difficulty โ€” 46 easy, 73 medium, 30 hard โ€” so you can choose the right level for your preparation.

Every question includes a detailed explanation to help you understand the concept, not just memorize answers. Take a timed quiz to simulate exam conditions, or practice at your own pace with no time limit.