10 questions🇬🇧English

🧱 Object-Oriented Programming – A-level

Computer Science · A-level — practise classes, objects, encapsulation, inheritance, polymorphism and class diagrams.

Make it your own private quiz and change anything you like

Questions

In object-oriented programming, what is an object?

An instance of a class
A template that defines attributes and methods
A variable that can store only one value
A subroutine that always returns a value
20s

What is the main purpose of a constructor?

To return the value of a private attribute
To state which superclass a subclass inherits from
To delete an object when it is no longer needed
To initialise a new object's attributes when it is created
20s

Which term describes bundling data with the methods that use it and hiding the data from direct outside access?

Aggregation
Encapsulation
Inheritance
Polymorphism
20s

In a UML class diagram, what does a minus sign (−) before an attribute show?

The attribute is static
The attribute is public
The attribute is private
The attribute is protected
20s

Why might a programmer use a setter method instead of making an attribute public?

It stops the attribute from ever being changed
Setter methods make the program run faster
The setter can validate a value before storing it
It lets subclasses override the attribute directly
30s

A subclass defines a method with the same name and parameters as one in its superclass, replacing it. What is this called?

Method overloading
Encapsulation
Instantiation
Method overriding
20s

Which of these is a genuine advantage of object-oriented programming?

Classes can be reused in other programs with little change
Classes need no testing once they have been written
OOP programs always run faster than procedural ones
OOP programs always use less memory than others
30s

Animal.speak() returns "Noise". Cat(Animal) overrides it to return "Meow". Kitten(Cat) adds nothing. What does Kitten().speak() return?

"Noise" followed by "Meow"
"Meow"
An error, as Kitten has no speak method
"Noise"
30s

Circle and Square both override Shape's area(). Calling area() on each item in a list of Shapes runs the right version. What is this?

Polymorphism
Instantiation
Encapsulation
Aggregation
30s

A Team object stores references to Player objects. The Players still exist if the Team is deleted. Which relationship is this?

Encapsulation
Composition
Inheritance
Aggregation
30s