Programming questions

By Interwoven Maths

Programming question collection

Review Programming questions for Computer Science, with correct answers shown and coverage across variables and operators; selection and iteration; procedures and functions.

Back to Programming practice Back to Computer Science

Question 1

What does variable scope determine?
  1. Where the variable can be accessed
  2. Which data type the variable stores
  3. Which value the variable currently holds
  4. How much memory the variable reserves

Question 2

What is defensive design mainly used for?
  1. Handling invalid input and unexpected use
  2. Reducing execution time for valid input
  3. Choosing meaningful names for identifiers
  4. Translating source code into machine code

Question 3

In Python, what does int(4.9) return?
  1. 4
  2. 5
  3. 4.9
  4. Error

Question 4

In Python file handling, what does mode 'a' do?
  1. Opens a file for appending
  2. Opens a file for reading
  3. Opens a file for writing and overwrites existing content
  4. Creates a read-only temporary copy

Question 5

Which three control structures are fundamental in structured programming?
  1. Sequence, selection and iteration
  2. Input, output and storage
  3. Sort, search and merge
  4. Syntax, semantics and style

Question 6

How does a function differ from a procedure?
  1. A function returns a value to its caller
  2. A procedure returns a value to its caller
  3. A function runs without being called
  4. A procedure receives parameters from its caller

Question 7

Why should identifier names be meaningful?
  1. To make each variable's purpose clear
  2. To show the indentation level
  3. To validate input values
  4. To convert runtime errors into syntax errors

Question 8

Which data type stores whole numbers?
  1. Integer
  2. Real
  3. Boolean
  4. Character

Question 9

Which data type stores true/false?
  1. Boolean
  2. Integer
  3. String
  4. Character

Question 10

Which operator gives the remainder?
  1. MOD
  2. DIV
  3. /
  4. *

Question 11

Which Boolean operator is true only when both conditions are true?
  1. AND
  2. OR
  3. NOT
  4. XOR

Question 12

Which Boolean operator is true when at least one condition is true?
  1. OR
  2. AND
  3. NOT
  4. DIV

Question 13

What is the result of applying NOT to TRUE?
  1. FALSE
  2. TRUE
  3. 1
  4. NULL

Question 14

What is a one-dimensional array used for?
  1. Store multiple values under one identifier
  2. Store one value under one identifier
  3. Store multiple values under two indices
  4. Store multiple values in a permanent file

Question 15

What is a record used for?
  1. Store related fields about one item
  2. Store same-type items under indices
  3. Process items in first-in-first-out order
  4. Process items in last-in-first-out order

Question 16

What does a range check do in validation?
  1. It checks that data is within set limits
  2. It checks that data has the correct type
  3. It checks that required data is not blank
  4. It checks that data has the correct length

Question 17

What does type casting do?
  1. Converts a value to another data type
  2. Encrypts a value for storage
  3. Sorts values into order
  4. Deletes invalid values automatically

Question 18

What does string concatenation do?
  1. Joins strings together
  2. Splits a string into characters
  3. Converts text to binary
  4. Counts the length of a string

Question 19

What is validation?
  1. Checking that input data is sensible
  2. Checking entered data against the original source
  3. Correcting invalid data automatically
  4. Testing whether an algorithm is efficient

Question 20

What is a logic error?
  1. Code runs but produces an incorrect result
  2. Code that cannot be parsed
  3. An error that stops a program while it runs
  4. Data outside a permitted input range

Question 21

What is a two-dimensional array used for?
  1. Store values under row and column indices
  2. Store values under one index
  3. Store one value under one identifier
  4. Store related fields about one item

Question 22

What is boundary test data chosen to check?
  1. Values at the edges of allowed ranges
  2. Typical values well inside allowed ranges
  3. Values copied from the original source
  4. Values stored in a different data type

Question 23

What is iteration?
  1. Repeating a set of instructions
  2. Selecting a path using a condition
  3. Executing instructions in a fixed order
  4. Calling a named subroutine

Question 24

What is normal test data?
  1. Data that should be accepted by a program
  2. Data just outside an allowed boundary
  3. A missing required value
  4. Data chosen to test a boundary

Question 25

Which value cannot change while a program runs?
  1. A constant
  2. A variable
  3. An array element
  4. An input

Question 26

Which construct chooses between two paths?
  1. Selection
  2. Sequence
  3. Iteration
  4. Assignment

Question 27

Which operator tests whether one value is less than another?
  1. Less than
  2. Equals
  3. Plus
  4. AND

Question 28

Which statement collects a value typed by the user?
  1. An input statement
  2. An output statement
  3. An assignment statement
  4. A comment

Question 29

What does a random number generator produce?
  1. An unpredictable value in a range
  2. The same value every time
  3. The largest value in a list
  4. A value typed by the user

Question 30

What is passed into a subroutine when it is called?
  1. An argument
  2. A return value
  3. A comment
  4. A data type

Question 31

What does an authentication routine check?
  1. Who the user is
  2. Whether data is sensible
  3. How fast the program runs
  4. Which data type is used

Question 32

When does iterative testing take place?
  1. While the program is being written
  2. Only once the program is finished
  3. Only when an error appears
  4. Only during the design stage

About this topic

Review Programming questions for Computer Science, with correct answers shown and coverage across variables and operators; selection and iteration; procedures and functions.

This topic covers

Example question types