Hamburg Abitur Computer Science - independent foundations study materials
Hamburg Abitur Computer Science - independent foundations study resources

Hamburg Abitur Computer Science - independent foundations practice questions

One question at a time. Build your Hamburg Abitur Computer Science - 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 object-oriented modelling, what does an „ist-ein“ relationship typically represent?

  1. Inheritance / specialisation between a subclass and a superclass Correct answer.
  2. Composition of parts that cannot exist without the whole
  3. A temporary method call between unrelated objects
  4. A network cable connecting two computers

Explanation

„Ist-ein“ (is-a) models inheritance or specialisation: a subclass is a specialised kind of its superclass. „Hat-ein“/„benutzt“ cover other relationships.

Question 2Programming, object modelling and software development

A School „has“ many Students that can enrol independently of any particular School object lifetime. Which relationship best fits?

  1. Inheritance (is-a)
  2. Association or aggregation (has-a / benutzt) without exclusive lifetime coupling Correct answer.
  3. Composition with exclusive ownership
  4. Polymorphism via an abstract interface only

Explanation

Students related to a School are typically modelled as association/aggregation (has-a). Composition implies exclusive part lifetime tied to the whole.

Question 3Programming, object modelling and software development

In a UML class diagram, which elements belong inside a class box?

  1. Only the class name; attributes and methods are drawn as separate boxes
  2. Only method names; attributes are never shown
  3. Class name plus attributes and methods (operations) Correct answer.
  4. Only network ports and IP addresses

Explanation

A class box shows the class name and typically attributes and methods that define the type’s shared properties and behaviour.

Question 4Programming, object modelling and software development

What is a constructor?

  1. A method that permanently deletes an object from memory by name
  2. A static global variable shared by all packages
  3. A UML stereotype for inheritance arrows only
  4. A special operation that initialises a new object of a class Correct answer.

Explanation

A constructor creates/initialises a new instance, typically setting attributes. It is a core Fachbegriff listed in A-Heft Aufgabe I.

Question 5Programming, object modelling and software development

What does a method signature typically specify?

  1. The method name and parameter types (and often return type), identifying the operation Correct answer.
  2. Only the runtime memory address of the object
  3. Only the colour of the UML box
  4. The private encryption key of the class

Explanation

A signature identifies a method by name and parameter (and commonly return) types so calls and overloads can be resolved.

Question 6Programming, object modelling and software development

An abstract class is best described as:

  1. A class that must contain only static final constants
  2. Any class without attributes
  3. A class that forbids inheritance
  4. A class that cannot be instantiated and may declare abstract methods for subclasses to implement Correct answer.

Explanation

Abstract classes define shared structure/behaviour but are incomplete; they are not instantiated directly and often declare abstract methods for subclasses.

Question 7Programming, object modelling and software development

Polymorphism in OO design means that:

  1. Two classes may never share a method name
  2. Objects of different subclasses can be used via a common type, with the appropriate method implementation selected at runtime Correct answer.
  3. Every attribute must be public
  4. Only one object may exist per class (singleton) always

Explanation

Polymorphism lets a common interface/supertype handle different subclass behaviours (dynamic dispatch). A-Heft eA expects candidates to explain it with examples.

Question 8Programming, object modelling and software development

Which statement best distinguishes aggregation from composition?

  1. Aggregation is inheritance; composition is method overloading
  2. They are identical UML relationships with different arrow colours only
  3. Composition implies stronger whole–part ownership (parts typically do not live independently); aggregation is a weaker has-a Correct answer.
  4. Aggregation applies only to primitive types; composition only to strings

Explanation

Both are has-a styles; composition models exclusive lifetime coupling of parts to the whole, while aggregation is looser.

Question 9Programming, object modelling and software development

High cohesion and low coupling in a class model generally indicate:

  1. A poorly structured design that should be rewritten randomly
  2. That all methods must be abstract
  3. That inheritance depth must be maximised
  4. Classes with focused responsibilities and limited unnecessary dependencies Correct answer.

Explanation

A-Heft eA asks candidates to assess models regarding Kohäsion and Kopplung: high cohesion and low coupling are usually desirable.

Question 10Programming, object modelling and software development

Object communication in an OO model is primarily realised by:

  1. Sending messages / calling methods on other objects Correct answer.
  2. Editing the UML diagram colours at runtime
  3. Changing the school’s Abitur timetable
  4. Replacing inheritance with global variables only

Explanation

Objects collaborate by invoking each other’s methods (message passing). A-Heft expects candidates to explain communication regarding a model.

Question 11Programming, object modelling and software development

A parameter of a method is:

  1. Always identical to a class attribute
  2. An input value (or object) supplied to the method when it is called Correct answer.
  3. The return type only
  4. A UML package name

Explanation

Parameters are values/objects passed into a method; they appear in the signature and are distinct from (though sometimes assigned to) attributes.

Question 12Programming, object modelling and software development

In Java, if attribute balance is private, code outside the class typically accesses it by:

  1. Using public getters/setters or other allowed methods defined by the class Correct answer.
  2. Directly writing account.balance from any package without restriction
  3. Changing the JVM timezone
  4. Renaming the class to public

Explanation

Private attributes enforce encapsulation; external code uses controlled methods (e.g., getters/setters) rather than direct field access.

Question 13Programming, object modelling and software development

A return value of a method is:

  1. Always void in every language
  2. The result handed back to the caller when the method finishes Correct answer.
  3. Identical to a constructor name
  4. Only used in functional languages, never in Java/Python

Explanation

The return value (Rückgabewert) is what the method yields to its caller; void/None means no useful value is returned.

Question 14Programming, object modelling and software development

Control structures needed to implement OO models include:

  1. Only inheritance arrows, never loops or conditionals
  2. Only Diffie–Hellman rounds
  3. Conditionals and loops (and related control flow) in Python or Java Correct answer.
  4. Only Kruskal edge sorts

Explanation

A-Heft expects correct use of Kontrollstrukturen in Python/Java when implementing models, alongside types and collections.

Question 15Programming, object modelling and software development

When modelling a library system, Book and Author are separate classes linked by association. Why not merge them into one class?

  1. Authors and books have distinct identities/responsibilities; merging lowers cohesion and confuses state Correct answer.
  2. UML forbids more than one class per diagram
  3. Association is illegal in A-Heft models
  4. Only inheritance is allowed between domain nouns

Explanation

Separate classes with clear responsibilities improve cohesion. A book is not an author; linking them models reality better than one bloated class.

Question 16Programming, object modelling and software development

Elementare Datentypen (e.g., int, boolean) differ from object types because they:

  1. Are identical to class instances in every language
  2. Represent simple values rather than instances of user-defined classes Correct answer.
  3. Cannot appear as method parameters
  4. Exist only in Scheme, never in Java or Python

Explanation

Primitive/elementary types hold simple values; object types refer to class instances. A-Heft lists both as Fachbegriffe for explaining code.

Question 17Programming, object modelling and software development

Tight coupling between classes often appears when:

  1. Each class has a single clear responsibility and communicates via narrow interfaces
  2. Classes depend on many concrete details of each other, so changes ripple widely Correct answer.
  3. No methods exist in either class
  4. Only primitive attributes are used

Explanation

High Kopplung means strong mutual dependence. Prefer narrow interfaces and high cohesion (eA model evaluation).

Question 18Programming, object modelling and software development

Identifying objects from a textual scenario is the first step of:

  1. Kruskal’s MST construction
  2. Frequency analysis of ciphertext
  3. Object-oriented analysis/modelling of a Realitätsausschnitt Correct answer.
  4. Diffie–Hellman modular exponentiation

Explanation

A-Heft Aufgabe I begins by analysing a description, identifying objects, and stating properties and capabilities.

Question 19Programming, object modelling and software development

Why document „hat-ein“ vs „ist-ein“ explicitly when modelling?

  1. Different relationship kinds imply different structure, lifetime, and inheritance semantics that must be justified Correct answer.
  2. A-Heft forbids relationship justification
  3. Only one relationship type exists in UML
  4. Relationships are chosen randomly each Klausur

Explanation

Candidates must model and justify relationships; confusing is-a with has-a produces incorrect class diagrams and code.

Question 20Programming, object modelling and software development

An abstract method in an abstract class typically:

  1. Contains a full implementation that subclasses must not change
  2. Declares an operation without implementation for subclasses to provide Correct answer.
  3. Is identical to a private final field
  4. Encrypts RSA messages automatically

Explanation

Abstract methods declare an interface for subclasses to implement, enabling polymorphic use of the abstract type.

Question 21Programming, object modelling and software development

In modelling, a method that needs many unrelated parameters often signals:

  1. Possible weak abstraction-responsibilities or a missing object/type may be hidden in the parameter list Correct answer.
  2. Perfect encapsulation with no design smell
  3. That UML class diagrams are banned
  4. That only functional languages can implement it

Explanation

Long unrelated parameter lists often mean the model should introduce types or split responsibilities (design judgement linked to cohesion).

Question 22Programming, object modelling and software development

Endrekursion (tail recursion) is recursion where:

  1. The recursive call is the final action, enabling iterative-like behaviour Correct answer.
  2. Every function must call two recursive branches always
  3. Recursion is forbidden in Scheme/Haskell
  4. The base case is never reached

Explanation

A-Heft eA asks candidates to recognise and explain Endrekursion when visualising recursive processes (crypto/search functional models).

Question 23Programming, object modelling and software development

Functions as parameters (eA functional paradigm) enable:

  1. Only storing integers in ArrayList
  2. Passing behaviour into algorithms (higher-order functions) Correct answer.
  3. Disabling Kerckhoffs’ principle
  4. Forbidding recursion

Explanation

A-Heft eA expects working with functions as parameters in Scheme/Haskell-higher-order functional modelling for crypto/search contexts.

Question 24Algorithms, recursion and complexity

In computer science, abstraction is best described as which of the following?

  1. Hiding unnecessary details so a problem or system can be understood and managed at a higher level Correct answer.
  2. Writing out every single low-level instruction a processor executes
  3. Translating source code into machine language
  4. Measuring the time complexity of an algorithm

Explanation

Abstraction means focusing on the essential features of a problem while ignoring or hiding unnecessary details, which lets people reason about complex systems at a manageable level. The GACE objective treats abstraction as a foundational concept of computer science.

Question 25Algorithms, recursion and complexity

What is the decimal (base-10) value of the binary number 1011?

  1. 11 Correct answer.
  2. 13
  3. 9
  4. 23

Explanation

Each binary digit represents a power of two from right to left: 1x8 + 0x4 + 1x2 + 1x1 = 8 + 0 + 2 + 1 = 11. Converting between number bases is an explicit GACE Algorithms and Computational Thinking objective.

Question 26Algorithms, recursion and complexity

What is the hexadecimal representation of the decimal number 255?

  1. FF Correct answer.
  2. 100
  3. 0F
  4. F0

Explanation

Hexadecimal is base 16, where F equals 15. The value 255 equals 15x16 + 15 = FF, the largest two-digit hexadecimal number. Analyzing and converting representations of numbers in different bases is a GACE objective.

Question 27Algorithms, recursion and complexity

A student breaks the task of building a school website into smaller subtasks: design the layout, write the content, code the navigation, and test the pages. This approach best demonstrates which computational thinking practice?

  1. Problem decomposition Correct answer.
  2. Number base conversion
  3. Data encryption
  4. Operator precedence

Explanation

Problem decomposition is the practice of breaking a large, complex problem into smaller, more manageable subproblems that can be solved individually. Dividing the website project into layout, content, navigation, and testing tasks is a clear example.

Question 28Algorithms, recursion and complexity

An algorithm performs a single pass through a list of n items, doing constant work for each item. Which describes its time complexity?

  1. Linear, O(n) Correct answer.
  2. Quadratic, O(n^2)
  3. Logarithmic, O(log n)
  4. Constant, O(1)

Explanation

When the number of operations grows in direct proportion to the input size n, the running time is linear, written O(n). A single pass doing constant work per element is the canonical example of linear time.

Question 29Algorithms, recursion and complexity

A binary search is performed on a sorted list of 16 elements. What is the maximum number of comparisons needed to determine whether a target value is present?

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

Explanation

Binary search halves the search space with each comparison, so the maximum number of comparisons is floor(log2 n) + 1. For 16 elements, log2(16) = 4, giving a maximum of 5 comparisons. Calculating comparisons for binary search is a stated GACE objective.

Question 30Algorithms, recursion and complexity

Which essential component must every recursive algorithm include to avoid running forever?

  1. A base case (stopping condition) Correct answer.
  2. A nested loop
  3. A global variable
  4. A sorting step

Explanation

A recursive algorithm calls itself on smaller inputs and must include a base case, a condition under which it stops recursing and returns a direct result. Without a base case, the recursion never terminates. Identifying the base case is an explicit GACE objective.

Question 31Algorithms, recursion and complexity

Which problem is best characterized as one that cannot be solved exactly within a practical time, making a heuristic solution appropriate?

  1. Finding the absolute shortest route that visits hundreds of cities exactly once (the traveling salesman problem) Correct answer.
  2. Adding two integers together
  3. Finding the largest value in a list of ten numbers
  4. Reversing a short string of characters

Explanation

The traveling salesman problem grows so quickly with the number of cities that finding the guaranteed optimal route becomes computationally impractical for large inputs, so heuristics that find good-enough solutions are used. Recognizing when heuristic solutions are useful is a GACE objective.

Question 32Algorithms, recursion and complexity

A teacher explains the difference between random and pseudorandom numbers. Which statement is correct?

  1. Pseudorandom numbers are generated by a deterministic algorithm from a seed and will repeat if the same seed is used Correct answer.
  2. Pseudorandom numbers can never be reproduced under any circumstances
  3. Truly random numbers are always produced by software loops
  4. Pseudorandom and truly random numbers are identical in every way

Explanation

Pseudorandom number generators use a deterministic algorithm starting from a seed value, so the same seed always produces the same sequence, which makes them reproducible. This distinguishes them from truly random sources, which derive from physical, unpredictable phenomena.

Question 33Algorithms, recursion and complexity

Consider the recursive definition: factorial(0) = 1, and factorial(n) = n * factorial(n - 1) for n > 0. What value does factorial(4) produce?

  1. 24 Correct answer.
  2. 12
  3. 16
  4. 10

Explanation

Tracing the recursion: factorial(4) = 4 * 3 * 2 * 1 * factorial(0) = 4 * 3 * 2 * 1 * 1 = 24. Tracing simple recursive algorithms such as n factorial is an explicit GACE objective.

Question 34Algorithms, recursion and complexity

A flowchart uses a diamond shape at a decision point. What does the diamond most commonly represent in standard flowchart notation?

  1. A condition or decision that branches the flow based on yes/no or true/false Correct answer.
  2. The start or end of the algorithm
  3. A simple process or calculation step
  4. Input or output of data

Explanation

In standard flowchart notation, the diamond represents a decision: a condition is evaluated and the flow branches based on the result, typically yes/no or true/false. Interpreting flowchart symbols and tracing algorithms in different formats is a GACE objective.

Question 35Algorithms, recursion and complexity

A student is given a table showing input values 1, 2, 3, 4 paired with outputs 1, 4, 9, 16. Which rule best describes the pattern that produces the outputs?

  1. Each output is the input squared Correct answer.
  2. Each output is the input plus three
  3. Each output is the input multiplied by four
  4. Each output is double the input

Explanation

Checking the pairs: 1^2 = 1, 2^2 = 4, 3^2 = 9, 4^2 = 16. The output equals the square of the input. Identifying patterns in a table of values and the algorithm that produces them is a GACE pattern-recognition objective.

Question 36Algorithms, recursion and complexity

An algorithm using nested loops compares every element of a list to every other element. As the list size n grows large, which growth rate best describes the number of comparisons?

  1. Quadratic, proportional to n^2 Correct answer.
  2. Linear, proportional to n
  3. Logarithmic, proportional to log n
  4. Constant, independent of n

Explanation

When an inner loop runs n times for each of the n iterations of an outer loop, the total number of comparisons is proportional to n times n, which is n^2, or quadratic growth. The GACE objective asks teachers to identify and compare linear, quadratic, exponential, and logarithmic algorithms.

Question 37Algorithms, recursion and complexity

Which list of items represents an abstraction hierarchy correctly ordered from the lowest (most detailed) level to the highest (most abstract) level?

  1. Transistors, logic gates, integrated circuits, computer Correct answer.
  2. Computer, integrated circuits, logic gates, transistors
  3. Logic gates, transistors, computer, integrated circuits
  4. Integrated circuits, computer, transistors, logic gates

Explanation

Abstraction hierarchies build from the most detailed physical components upward. Transistors combine into logic gates, gates form integrated circuits, and circuits make up the complete computer, moving from low (detailed) to high (abstract). Ordering an abstraction hierarchy is a GACE objective.

Question 38Algorithms, recursion and complexity

An algorithm's running time doubles every time one additional input element is added. Which growth rate does this describe?

  1. Exponential Correct answer.
  2. Linear
  3. Logarithmic
  4. Constant

Explanation

If adding one element doubles the work, the running time grows as a power of two with respect to input size, which is exponential growth. Exponential algorithms quickly become infeasible for large inputs, a key idea in the GACE limitations objective.

Question 39Algorithms, recursion and complexity

A selection sort repeatedly finds the smallest remaining element and places it at the front of the unsorted portion. After the first full pass over an unsorted list, which statement is guaranteed to be true?

  1. The smallest element is now in the first position Correct answer.
  2. The entire list is fully sorted
  3. The largest element is now in the first position
  4. No elements have changed position

Explanation

Selection sort scans the unsorted portion to find the minimum and swaps it into the next sorted position. After the first pass, the smallest element is correctly placed at the front. Tracing sorting algorithms and predicting intermediate results is a GACE objective.

Question 40Algorithms, recursion and complexity

Which application is the most appropriate use of randomization in computing?

  1. Shuffling a deck of cards in a digital card game Correct answer.
  2. Calculating the exact sum of a column of numbers in a spreadsheet
  3. Sorting a list of names into alphabetical order
  4. Converting a decimal number to binary

Explanation

Randomization is appropriate when unpredictability or fairness is desired, such as shuffling a virtual deck so each game deals a different arrangement. The GACE objective asks teachers to identify appropriate uses of randomization across applications.

Question 41Algorithms, recursion and complexity

A linear search examines a list of 100 unsorted items for a target value. In the worst case, how many items must it examine?

  1. 100 Correct answer.
  2. 7
  3. 50
  4. 1

Explanation

A linear search checks elements one at a time. In the worst case, the target is the last element or absent, so all 100 items must be examined. Calculating comparisons for linear search is a stated GACE objective.

Question 42Algorithms, recursion and complexity

A problem is described as undecidable, meaning no algorithm can ever solve it for all possible inputs. Which classic example fits this description?

  1. The halting problem: deciding whether an arbitrary program will eventually stop Correct answer.
  2. Adding two numbers stored in variables
  3. Searching a sorted array for a value
  4. Sorting a list of integers in ascending order

Explanation

The halting problem is the classic undecidable problem: no general algorithm can determine, for every possible program and input, whether the program will halt or run forever. Recognizing that some problems cannot be solved by a computer is a GACE objective.

Question 43Algorithms, recursion and complexity

An iterative algorithm uses a loop to compute the sum of the first n positive integers. Which recursive definition is equivalent?

  1. sum(n) = n + sum(n - 1), with sum(0) = 0 Correct answer.
  2. sum(n) = n * sum(n - 1), with sum(0) = 1
  3. sum(n) = sum(n - 1) - n, with sum(0) = 0
  4. sum(n) = n, with no base case

Explanation

The sum of the first n integers can be defined recursively by adding n to the sum of the first n-1 integers, with the base case sum(0) = 0. The GACE objective asks teachers to identify an iterative algorithm equivalent to a recursive one and vice versa.

Question 44Algorithms, recursion and complexity

When generalizing a solution through abstraction, a programmer should do which of the following?

  1. Remove details specific to one case so the solution applies to many similar cases Correct answer.
  2. Add as many case-specific constants as possible
  3. Convert all variables into fixed literal values
  4. Increase the number of nested loops regardless of need

Explanation

Generalization through abstraction means removing details tied to a single instance so the same solution works across many cases, often by introducing parameters or variables. Identifying details that can be removed to generalize a solution is an explicit GACE objective.

Question 45Algorithms, recursion and complexity

A recursive function to compute n factorial is missing its base case. What is the most likely consequence of running it?

  1. Infinite recursion that eventually causes a stack overflow Correct answer.
  2. It returns the correct factorial faster than an iterative version
  3. It automatically converts itself to a loop
  4. It produces a syntax error before any code runs

Explanation

Without a base case, the function keeps calling itself on ever-smaller (or unchanging) inputs and never stops, consuming stack space until a stack overflow occurs. Identifying errors in simple recursive algorithms and the role of the stopping condition is a GACE objective.

Question 46Algorithms, recursion and complexity

Two algorithms solve the same problem. Algorithm A runs in O(n) time and Algorithm B runs in O(n^2) time. For very large inputs, which statement is generally true?

  1. Algorithm A is more efficient and will typically finish faster than Algorithm B Correct answer.
  2. Algorithm B is always faster because it does more work
  3. The two algorithms always take exactly the same amount of time
  4. Time complexity has no effect on running time for large inputs

Explanation

For large n, a linear-time algorithm scales much better than a quadratic-time one, so Algorithm A typically finishes faster. Comparing algorithms by efficiency is a GACE objective under analysis of searching and sorting algorithms.

Question 47Algorithms, recursion and complexity

A simulation models traffic flow but produces results that do not match reality because it ignores pedestrian crossings. Adding a variable to represent pedestrian crossings is an example of which idea?

  1. Refining a model by adding variables to improve its accuracy Correct answer.
  2. Converting the model from binary to decimal
  3. Encrypting the simulation data
  4. Reducing the abstraction level of the network protocol

Explanation

Adding a relevant variable, such as pedestrian crossings, refines a simulation so it better reflects the real system. The GACE Data objective notes that changes to a simulation, such as adding more variables or data, affect how well it models reality.

Question 48Digital 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 49Digital 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 50Digital 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.