Lesson 4.1.2.3

4.1.2.3 Object-oriented programming and class diagrams Quiz: AQA Computer Science, Unit 1

20 questions

In partnership with Revision Ninja

Lesson 4.1.2.3, Object-oriented programming and class diagrams: 20 multiple choice questions for the AQA Computer Science (7517), Unit 1: Fundamentals of programming, written with Revision Ninja.

Host it live on the board and students join with a game code on their own devices, or revise alone with Free Play. The answers are revealed in the game.

Host this setFree Play

The 20 questions

  1. In object-oriented programming, what is a class?

    • A single value stored in memory, which can be read and changed by any part of the program
    • A file that stores objects on disk, with each object saved as one line of text in the file
    • A blueprint that defines the attributes and methods shared by objects
    • A loop that repeats until a condition is met, with the test made at the start of each pass
  2. What is an object?

    • A type of subroutine with no parameters, which returns a single value to the calling code
    • An instance created from a class, holding its own attribute values
    • A text file containing class names, which the program reads to find each class at runtime
    • A constant declared at the start of a program, with a fixed value that cannot change later
  3. What is instantiation?

    • The process of creating an object from a class
    • The process of deleting a class from memory
    • The process of drawing a class diagram
    • The process of converting a string to an integer
  4. What does encapsulation mean?

    • Using a loop to repeat a method
    • Grouping data and methods together and controlling access to the data
    • Making every attribute public so it can be changed by any code
    • Copying a class to create a new one
  5. What is inheritance?

    • A way to convert objects to strings, so that each object can be printed as readable text
    • A way for one class to take on the attributes and methods of another class
    • A way to store objects in a binary file, saving each object's fields as raw bytes on disk
    • A way for a constant to be shared between programs, so that every program uses the same value
  6. What is polymorphism?

    • The ability of different objects to respond to the same method call in their own way
    • The ability to store a number in several data types, so the same value can be used as text
    • The ability of a class to have no methods, so it stores data only and never runs any code
    • The ability of a loop to run in reverse, counting down from the end of a list to the start
  7. What is overriding a method?

    • Deleting a method so that it cannot be called, which removes it from the class completely
    • Providing a new implementation in a subclass for a method inherited from a parent class
    • Making a method static so it belongs to the class, rather than to each object created from it
    • Copying a method into a file, so that it can be stored and loaded again at a later time
  8. In UML, which symbol represents composition?

    • A dashed arrow
    • A plain line with no symbol
    • A black diamond line
    • A white diamond line
  9. In UML, how is aggregation represented?

    • A dotted line with a circle
    • A white diamond line
    • A double-headed arrow
    • A black diamond line
  10. In a class diagram, what do the symbols +, - and # indicate?

    • Public, private and protected visibility of members
    • Addition, subtraction and hashing, which are the arithmetic operations the diagram shows
    • Read, write and execute permissions, which control the file access of each class in use
    • Positive, negative and zero values, which mark the sign of each attribute in the class
  11. Why does object-oriented programming suit large systems?

    • It removes the need for any data storage, so the system keeps all values in memory only
    • It guarantees that every program is fast, because objects are always stored in the cache
    • Objects model real-world entities and encapsulate their behaviour, which helps organise and reuse code
    • It avoids the need for methods, so each object holds data and its behaviour is inferred
  12. Which principle is described by the phrase favour composition over inheritance?

    • Build a class from objects it contains rather than relying only on a parent class
    • Avoid using objects in any program, and write each task as a standalone subroutine instead
    • Use only static methods in every class, so that no object has to be created before a call
    • Always create the deepest possible class hierarchy, so that every class inherits from many parents
  13. A class Car has an attribute engine of type Engine. The Car is destroyed when the Engine must not exist independently. Which relationship is this?

    • Aggregation
    • Inheritance
    • Polymorphism
    • Composition
  14. A class Department contains a list of Teacher objects that exist independently of the Department. Which relationship fits best?

    • Composition
    • Overriding
    • Aggregation
    • Encapsulation
  15. A class Animal has a method speak, and a subclass Dog overrides speak to bark. What is printed if a Dog object's speak is called?

    • the Animal default sound only
    • bark
    • an error, because overriding is not allowed
    • speak
  16. Which access modifier makes an attribute usable only within its own class?

    • private
    • public
    • protected
    • static
  17. Which access modifier allows a member to be used in subclasses but not by unrelated code?

    • private
    • protected
    • public
    • abstract
  18. What is an abstract method?

    • A method declared without an implementation, which subclasses must provide
    • A method that can only be called from outside the program, never from inside the same class
    • A method that is always private, so that only the class's own code can call it at any time
    • A method that returns a random value, which changes each time it is called by the program
  19. What is a static method?

    • A method that changes every object in memory, updating the state of all objects at one time
    • A method that belongs to the class rather than to any one object
    • A method that is always overridden, so each subclass must write its own version of it
    • A method that cannot take parameters, so it always works on fixed values stored in the class
  20. A class diagram shows a class with attributes listed under the name and methods listed below. Which section lists the methods?

    • The bottom section
    • The top section
    • The middle section only
    • A separate file

All AQA Computer Science quizzes