Hesse Abitur Computer Science, basic course - independent foundations study materials
Hesse Abitur Computer Science, basic course - independent foundations study resources

Hesse Abitur Computer Science, basic course - independent foundations practice questions

One question at a time. Build your Hesse Abitur Computer Science, basic course - independent foundations understanding.

First 50 of 190 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.

Continue in the practice tool above to load more questions, 50 at a time.

Question 1Programming, object modelling and software development

In a program, the three basic constructs used to control the flow of execution are which of the following?

  1. Sequence, selection, and iteration Correct answer.
  2. Compilation, interpretation, and assembly
  3. Encryption, decryption, and hashing
  4. Stacks, queues, and dictionaries

Explanation

The three fundamental programming constructs are sequence (statements in order), selection (branching with conditionals), and iteration (repetition with loops). Understanding these three constructs is an explicit GACE Programming objective.

Question 2Programming, object modelling and software development

Using standard operator precedence, what is the value of the expression 2 + 3 * 4?

  1. 14 Correct answer.
  2. 20
  3. 11
  4. 24

Explanation

Multiplication has higher precedence than addition, so 3 * 4 is evaluated first to get 12, then 2 + 12 = 14. Applying operator precedence to evaluate expressions is a GACE Programming objective.

Question 3Programming, object modelling and software development

Consider the pseudocode: x <- 5; y <- x + 3; x <- x * 2; print x; print y. What is printed?

  1. 10 and 8 Correct answer.
  2. 5 and 8
  3. 10 and 16
  4. 16 and 10

Explanation

Tracing in order: x becomes 5, then y becomes 5 + 3 = 8, then x becomes 5 * 2 = 10. Printing x then y outputs 10 and 8. The value of y was fixed when computed and is not affected by the later change to x. Tracing code to determine variable values is a GACE objective.

Question 4Programming, object modelling and software development

A program statement reads: if (age >= 18) then print "adult" else print "minor". When age is exactly 18, what is printed?

  1. adult Correct answer.
  2. minor
  3. Nothing is printed
  4. Both adult and minor

Explanation

The relational operator >= means greater than or equal to, so the condition age >= 18 is true when age is exactly 18, and the program prints "adult". Understanding relational operators and selection is a GACE Programming objective.

Question 5Programming, object modelling and software development

A loop is written as: count <- 0; while (count < 3) { print count; count <- count + 1 }. What does the loop print?

  1. 0 1 2 Correct answer.
  2. 1 2 3
  3. 0 1 2 3
  4. 0 1 2 3 4

Explanation

The loop starts with count = 0 and continues while count is less than 3. It prints 0, increments to 1, prints 1, increments to 2, prints 2, increments to 3, then the condition fails and the loop stops. The output is 0 1 2. Tracing iteration is a GACE objective.

Question 6Programming, object modelling and software development

A programmer replaces the literal value 3.14159 used many times throughout a program with a named constant PI. Which benefit most directly results from this change?

  1. Improved maintainability, since the value can be updated in one place Correct answer.
  2. Faster network transmission of the program
  3. Automatic encryption of the program's output
  4. Conversion of the program from interpreted to compiled

Explanation

Using a named constant means the value is defined once and referenced by name, so any future change requires editing only one location, improving maintainability and reducing errors. Identifying situations where constants are preferred over hard-coded values is a GACE objective.

Question 7Programming, object modelling and software development

A program attempts to divide a number by a variable whose value is zero while the program is running, causing it to crash. This is best classified as which type of error?

  1. A runtime error Correct answer.
  2. A syntax error
  3. A compile-time spelling error
  4. A documentation error

Explanation

Division by zero occurs while the program executes, not when it is being translated, so it is a runtime error. The GACE objective asks teachers to identify the type of error produced by a code segment, including syntax, runtime, overflow, round-off, and logic errors.

Question 8Programming, object modelling and software development

A program adds the integer 1 to a variable that already holds the maximum value its data type can store, and the result wraps around to a large negative number. This is an example of which type of error?

  1. An overflow error Correct answer.
  2. A syntax error
  3. A logic error in a comment
  4. A round-off error in floating point addition

Explanation

When a value exceeds the largest number a fixed-size data type can represent, it overflows and wraps around, often to a negative value. Differentiating among error types including overflow is an explicit GACE objective.

Question 9Programming, object modelling and software development

Which data type is most appropriate for storing a person's exact age in whole years?

  1. Integer Correct answer.
  2. Floating point
  3. String
  4. Boolean

Explanation

Age in whole years is a counting number with no fractional part, so an integer is the most appropriate and efficient choice. Identifying the most appropriate data type in a given context is a GACE Programming objective.

Question 10Programming, object modelling and software development

In the pseudocode notation used on the GACE assessment, the operator / indicates floating point division unless stated otherwise. What is the value of 7 / 2?

  1. 3.5 Correct answer.
  2. 3
  3. 4
  4. 1

Explanation

Floating point division keeps the fractional part, so 7 / 2 = 3.5. The GACE pseudocode notation explicitly states that / indicates floating point division unless otherwise noted. Describing the difference between integer and floating point division is a GACE objective.

Question 11Programming, object modelling and software development

A function is defined as area(length, width) returns length * width. A program calls area(4, 5). What value is returned?

  1. 20 Correct answer.
  2. 9
  3. 45
  4. 4

Explanation

The arguments 4 and 5 are passed to the parameters length and width, and the function returns length * width = 4 * 5 = 20. Tracing code that calls procedures with parameters and return values is an explicit GACE objective.

Question 12Programming, object modelling and software development

Which scenario best describes an event-driven program?

  1. A program that runs a specific function whenever the user clicks a button Correct answer.
  2. A program that prints the numbers 1 through 10 and then stops
  3. A program that converts a decimal number to binary once
  4. A program that calculates the average of a fixed list of grades

Explanation

Event-driven programs respond to external events such as clicks, key presses, sensor readings, or messages, executing handler code when an event occurs. Running a function when a button is clicked is the defining example. The GACE objective covers event-driven programs that respond to external events.

Question 13Programming, object modelling and software development

Using the GACE Boolean operators, what is the value of the expression (true and false) or (not false)?

  1. true Correct answer.
  2. false
  3. null
  4. It cannot be evaluated

Explanation

Evaluate the parts: (true and false) is false because both operands must be true for and; (not false) is true. Then false or true is true. Using Boolean algebra to evaluate expressions is a GACE objective.

Question 14Programming, object modelling and software development

Which Boolean expression is equivalent to not (A and B) according to De Morgan's laws?

  1. (not A) or (not B) Correct answer.
  2. (not A) and (not B)
  3. A or B
  4. A and B

Explanation

De Morgan's laws state that the negation of a conjunction equals the disjunction of the negations: not (A and B) is equivalent to (not A) or (not B). Identifying equivalent Boolean expressions is a GACE objective.

Question 15Programming, object modelling and software development

Which characteristic best describes a stack data structure?

  1. Last-in, first-out (LIFO) access, where the most recently added item is removed first Correct answer.
  2. First-in, first-out (FIFO) access, where the oldest item is removed first
  3. Key-value lookup, where each item is found by a unique key
  4. Direct random access to any element by numeric index only

Explanation

A stack follows last-in, first-out (LIFO) order: the most recently pushed item is the first one popped, like a stack of plates. The GACE objective requires familiarity with stacks, queues, and dictionaries/maps and their behavior.

Question 16Programming, object modelling and software development

A program must store and look up a student's grade by the student's unique ID number. Which data structure is the most appropriate choice?

  1. A dictionary (map) that associates each ID key with a grade value Correct answer.
  2. A stack that only allows access to the top element
  3. A queue that only allows removal from the front
  4. A single Boolean variable

Explanation

A dictionary or map stores key-value pairs and allows fast lookup of a value by its key, which exactly matches looking up a grade by a unique student ID. Choosing the most appropriate data structure for a context is a GACE objective.

Question 17Programming, object modelling and software development

In object-oriented programming, what does encapsulation primarily refer to?

  1. Bundling data and the methods that operate on it together while restricting direct access to internal state Correct answer.
  2. Allowing one class to inherit attributes and methods from another
  3. Defining multiple methods with the same name but different parameters
  4. Translating source code into machine code

Explanation

Encapsulation bundles an object's data (fields) and the methods that act on that data into a single unit and hides internal details, exposing a controlled interface. The GACE objective asks teachers to identify the benefits of inheritance and encapsulation.

Question 18Programming, object modelling and software development

A subclass Dog defines its own version of a method speak() that already exists in its parent class Animal, replacing the inherited behavior. This is an example of which object-oriented concept?

  1. Method overriding Correct answer.
  2. Method overloading
  3. Encapsulation
  4. Compilation

Explanation

Overriding occurs when a subclass provides its own implementation of a method that is already defined in its superclass, replacing the inherited behavior for instances of the subclass. Distinguishing between overloading and overriding is a GACE objective.

Question 19Programming, object modelling and software development

What is the key difference between a compiler and an interpreter?

  1. A compiler translates the entire program into machine code before execution, while an interpreter translates and executes code line by line at runtime Correct answer.
  2. A compiler runs code line by line, while an interpreter translates everything first
  3. A compiler only works with binary numbers, while an interpreter only works with decimal numbers
  4. There is no functional difference between them

Explanation

A compiler translates the whole source program into machine (object) code ahead of time, producing an executable, whereas an interpreter reads, translates, and executes the source one statement at a time during runtime. Identifying differences between compilation and interpretation is a GACE objective.

Question 20Programming, object modelling and software development

Given an API function getMax(list) that returns the largest value in a list, which is the correct way to store the result for the list scores?

  1. highest <- getMax(scores) Correct answer.
  2. getMax(scores) <- highest
  3. highest getMax scores
  4. getMax <- scores(highest)

Explanation

To use a function's return value, you call the function with the proper argument and assign the returned result to a variable: highest <- getMax(scores). Identifying correct calls and use of return values from an API definition is a GACE objective.

Question 21Programming, object modelling and software development

A program reads a user's age from a text field. Which input validation strategy is most appropriate before using the value as a number?

  1. Check that the entry contains only digits and falls within a reasonable range before converting it Correct answer.
  2. Immediately store the raw text and never check it
  3. Print the entry to the screen and assume it is valid
  4. Encrypt the entry without checking its contents

Explanation

Effective input validation confirms that data has the proper format (only digits) and falls within an acceptable range before the program relies on it, preventing crashes and bad results. Identifying effective input data validation strategies is a GACE objective.

Question 22Programming, object modelling and software development

A teacher wants students to find a logic error in a program that always reports a list is empty even when it contains items. Which debugging technique is most useful for locating the error?

  1. Insert print statements to display variable values at key points during execution Correct answer.
  2. Delete the entire program and start over without analysis
  3. Change the programming language
  4. Encrypt the source code

Explanation

Inserting print statements to show variable values at strategic points lets the programmer observe where the logic diverges from expectations, a standard debugging technique. The GACE objective lists describing useful debugging techniques, such as where to put print statements, as a skill.

Question 23Programming, object modelling and software development

When testing a function that accepts whole numbers from 1 to 100, which set of test cases best includes useful boundary values?

  1. 0, 1, 100, and 101 Correct answer.
  2. Only 50
  3. Only large random numbers in the thousands
  4. Only negative decimals

Explanation

Boundary testing checks values at and just outside the edges of valid input: 1 and 100 are the boundaries, and 0 and 101 are the values just outside. Choosing test cases that are most useful for given code is a GACE objective.

Question 24Programming, object modelling and software development

Which practice is the clearest sign of well-documented, modular code?

  1. Meaningful comments and descriptive names organized into small, single-purpose functions Correct answer.
  2. One enormous function with single-letter variable names and no comments
  3. Code that relies entirely on hard-coded values repeated throughout
  4. Random indentation and inconsistent naming

Explanation

Good documentation and modular design use clear comments, descriptive identifiers, and small functions that each perform one task, making code readable and maintainable. Identifying characteristics of good documentation and modular programs is a GACE objective.

Question 25Programming, object modelling and software development

A development team uses code reviews, where peers read and comment on each other's code before it is merged. Which benefit most directly results from this practice?

  1. Catching errors and improving code quality through additional perspectives Correct answer.
  2. Automatically compiling the code into machine language
  3. Encrypting the source code for security
  4. Increasing the program's clock speed

Explanation

Code reviews bring additional perspectives that catch bugs, enforce standards, and improve overall quality before code is merged. The GACE objective identifies code reviews and peer feedback as techniques to produce high-quality code.

Question 26Programming, object modelling and software development

A program needs to repeat the same block of code an exact, known number of times. Which construct is most appropriate?

  1. A counted loop (for loop) Correct answer.
  2. A single if statement with no loop
  3. A function definition with no call
  4. A constant declaration

Explanation

When the number of repetitions is fixed and known in advance, a counted (for) loop is the most appropriate construct because it manages the counter automatically. Identifying which constructs are needed to implement given functionality is a GACE objective.

Question 27Programming, object modelling and software development

Consider the pseudocode: int[] a <- {3, 6, 9, 12}; print a[2]. Using zero-based indexing as in the GACE notation, what is printed?

  1. 9 Correct answer.
  2. 6
  3. 12
  4. 3

Explanation

With zero-based indexing, a[0] is 3, a[1] is 6, a[2] is 9, and a[3] is 12. Therefore a[2] prints 9. Tracing array references is part of the GACE Programming objectives on variables and data types.

Question 28Programming, object modelling and software development

A program declares a variable inside a function. Outside that function, the variable cannot be referenced. This behavior is best explained by which concept?

  1. Variable scope, specifically that the variable has local scope Correct answer.
  2. Operator precedence
  3. Floating point round-off
  4. Data encryption

Explanation

Scope determines where a variable can be accessed. A variable declared inside a function has local scope and is visible only within that function, not outside it. Distinguishing between global and local scope is a GACE objective.

Question 29Programming, object modelling and software development

A low-level programming language is best characterized by which property?

  1. It is close to machine code and offers fine control over hardware but is harder for humans to read Correct answer.
  2. It is highly abstract and reads almost like natural English
  3. It can never be translated into machine code
  4. It automatically manages all memory without programmer involvement

Explanation

Low-level languages, such as assembly, operate close to the hardware and machine code, giving precise control over the processor and memory at the cost of being harder for humans to read and write. Identifying characteristics of low- and high-level languages is a GACE objective.

Question 30Algorithms, recursion and complexity

What is the worst-case time complexity of binary search on a sorted array of n elements?

  1. O(log n) Correct answer.
  2. O(n)
  3. O(n log n)
  4. O(1)

Explanation

Binary search halves the search space each step, so worst-case comparisons grow as ⌈log₂(n+1)⌉, i.e. O(log n).

Question 31Algorithms, recursion and complexity

In the worst case, how many comparisons does linear search need to find a key in an unsorted array of 20 distinct elements?

  1. 20 Correct answer.
  2. 10
  3. ⌈log₂ 20⌉
  4. 1

Explanation

If the key is last or absent (depending on convention for present keys), linear search may examine all 20 elements - worst case 20 comparisons for a present last element.

Question 32Algorithms, recursion and complexity

Selection sort on n elements always performs how many swaps of whole elements (classic formulation that swaps once per outer pass)?

  1. n − 1 swaps in the outer loop Correct answer.
  2. n² swaps
  3. ⌈log₂ n⌉ swaps
  4. Exactly n/2 swaps always

Explanation

Classic selection sort finds the minimum for positions 0..n−2 and swaps once per outer iteration → n−1 swaps.

Question 33Algorithms, recursion and complexity

Insertion sort’s best-case time complexity on an already sorted array is:

  1. O(n) Correct answer.
  2. O(n²)
  3. O(log n)
  4. O(n log n)

Explanation

On sorted input each new element needs only one comparison (or a constant check) before inserting in place → linear best case.

Question 34Algorithms, recursion and complexity

Bubble sort (adjacent swaps until no swap occurs) on [3, 1, 2] performs how many adjacent swaps until sorted?

  1. 2 Correct answer.
  2. 0
  3. 3
  4. 6

Explanation

Pass 1: swap 3↔1 → [1,3,2]; swap 3↔2 → [1,2,3]. Two adjacent swaps; next pass finds no swaps.

Question 35Algorithms, recursion and complexity

Merge sort’s typical worst-case time complexity is:

  1. O(n log n) Correct answer.
  2. O(n)
  3. O(n²)
  4. O(2ⁿ)

Explanation

Merge sort divides in half (log n levels) and merges in linear work per level → Θ(n log n) worst case.

Question 36Algorithms, recursion and complexity

Which statement about stable sorting is correct?

  1. A stable sort preserves the relative order of equal keys Correct answer.
  2. Every O(n log n) sort is necessarily unstable
  3. Stability means the algorithm never uses extra memory
  4. Stability means worst-case O(n) time

Explanation

Stability: equal keys keep their original relative order (e.g., merge sort typically stable; naive quicksort not).

Question 37Algorithms, recursion and complexity

For n = 16, approximately how many comparisons does binary search need in the worst case (searching a present key)?

  1. About 4–5 Correct answer.
  2. Exactly 16
  3. Exactly 256
  4. Exactly 1

Explanation

log₂ 16 = 4; with integer mid rounding and inclusive bounds, worst case is about ⌈log₂(n+1)⌉ ≈ 4–5 comparisons.

Question 38Algorithms, recursion and complexity

Tail recursion means:

  1. The recursive call is the last action in the function Correct answer.
  2. The function never returns a value
  3. There are two recursive calls in every branch
  4. The base case is omitted

Explanation

In a tail-recursive function, after the recursive call nothing else is computed - enabling potential reuse of the stack frame.

Question 39Algorithms, recursion and complexity

How many times is the method body entered for a correct recursive countdown from n to 1 that prints n then calls countdown(n−1), starting at countdown(5)?

  1. 5 Correct answer.
  2. 4
  3. 6
  4. 1

Explanation

Calls for 5,4,3,2,1 - five entries that print; the call with 0 hits the base and returns without printing (if structured that way). If base is n<=0 return before print, still five printing entries.

Question 40Digital representation and data structures

How many bits are in one byte?

  1. 8 Correct answer.
  2. 4
  3. 16
  4. 1024

Explanation

By definition, one byte equals 8 bits. This is a foundational unit used in performing calculations with bits and bytes, a GACE Data objective.

Question 41Digital representation and data structures

An encoding scheme uses 8 bits to represent each character. How many distinct characters can it represent?

  1. 256 Correct answer.
  2. 8
  3. 128
  4. 16

Explanation

With n bits, you can represent 2 to the power n distinct values. For 8 bits, 2^8 = 256 distinct characters. Determining how many values a given number of bits can encode is a GACE Data objective.

Question 42Digital representation and data structures

Which statement correctly distinguishes lossy from lossless data compression?

  1. Lossless compression preserves all original data exactly, while lossy compression discards some data to achieve smaller file sizes Correct answer.
  2. Lossy compression always preserves every bit of the original data
  3. Lossless compression always produces smaller files than lossy compression
  4. There is no difference between lossy and lossless compression

Explanation

Lossless compression (for example, ZIP or PNG) lets the exact original data be reconstructed, while lossy compression (for example, JPEG or MP3) permanently discards some data to shrink files further. Describing lossy and lossless compression is a GACE Data objective.

Question 43Digital representation and data structures

A teacher explains the difference between encoding and encryption. Which statement is correct?

  1. Encoding transforms data into another format for usability and is easily reversible without a secret, while encryption secures data so it can be read only with a key Correct answer.
  2. Encoding and encryption are identical processes with the same purpose
  3. Encryption is used only to compress files, never to secure them
  4. Encoding requires a secret key to reverse, while encryption never does

Explanation

Encoding changes data into another format (such as ASCII or Base64) for storage or transmission and is reversible by anyone who knows the scheme, whereas encryption deliberately protects data so only a holder of the correct key can read it. Distinguishing encoding from encryption is a GACE Data objective.

Question 44Digital representation and data structures

Ordering common units of digital storage from smallest to largest, which sequence is correct?

  1. Kilobyte, megabyte, gigabyte, terabyte Correct answer.
  2. Gigabyte, megabyte, kilobyte, terabyte
  3. Terabyte, gigabyte, megabyte, kilobyte
  4. Megabyte, kilobyte, gigabyte, terabyte

Explanation

Each unit is roughly a thousand times larger than the previous: kilobyte, megabyte, gigabyte, then terabyte, from smallest to largest. Identifying measures of file size such as byte, kilo, mega, giga, tera, and peta is a GACE Data objective.

Question 45Digital representation and data structures

Approximately how many bytes are needed to store a plain-text document containing 2,000 characters, assuming one byte per character?

  1. About 2,000 bytes (roughly 2 kilobytes) Correct answer.
  2. About 16 bytes
  3. About 2 million bytes
  4. About 8 bytes

Explanation

If each character takes one byte, a 2,000-character document requires about 2,000 bytes, which is roughly 2 kilobytes. Determining the number of bits and bytes required to store a given amount of data is a GACE Data objective.

Question 46Digital representation and data structures

Why are binary numbers fundamental to the operation of computer systems?

  1. Digital hardware represents data using two-state electronic components, such as on/off or high/low voltage, which map naturally to the digits 0 and 1 Correct answer.
  2. Binary is the only number system that can represent fractions
  3. Binary uses ten digits, making it efficient for humans
  4. Binary cannot be converted to any other number base

Explanation

Computers are built from electronic components that have two stable states, commonly represented as 0 and 1, so binary is the natural language of digital hardware. Explaining why binary numbers are fundamental to computer systems is a GACE Data objective.

Question 47Digital representation and data structures

A run-length encoding scheme compresses the string AAAAA by storing it as 5A. This is an example of which kind of compression?

  1. Lossless compression, because the original string can be fully reconstructed Correct answer.
  2. Lossy compression, because data is permanently discarded
  3. Encryption, because the data is now secret
  4. Encoding into hexadecimal

Explanation

Run-length encoding records a count and the repeated symbol (5A for AAAAA) and allows the exact original string to be rebuilt, so it is lossless compression. Describing lossy and lossless compression is a GACE Data objective.

Question 48Digital representation and data structures

A given encoding scheme assigns A = 00, B = 01, C = 10, and D = 11. What string does the encoded sequence 011011 represent?

  1. BCD Correct answer.
  2. ABC
  3. DDB
  4. BDD

Explanation

Split the fixed-length sequence into two-bit groups from left to right: 01, 10, 11. These map to B, C, and D respectively, giving BCD. Decoding data given an encoding scheme is a GACE Data objective.

Question 49Entity modelling, relational algebra and SQL

In the relational model, a relation is mathematically a:

  1. Set of tuples over a fixed attribute schema Correct answer.
  2. Unordered bag of nested tables only
  3. Single linked list of bytes
  4. Finite automaton

Explanation

A relation ⊆ D1 × … × Dk; practical SQL tables approximate multisets but the model starts from sets of tuples.

Question 50Entity modelling, relational algebra and SQL

Which SQL clause is used to filter rows based on a condition?

  1. ORDER BY
  2. GROUP BY
  3. WHERE Correct answer.
  4. INSERT

Explanation

The WHERE clause restricts a query's result to rows that satisfy a given condition. ORDER BY sorts results, GROUP BY aggregates them, and INSERT adds new rows.