IB Diploma Programme (DP) - SL & HL · Computer Science

Classes, objects and encapsulation: Practice Questions

5 multiple-choice questions marked as you go, and 5 written questions with worked solutions. All on Classes, objects and encapsulation.

10 questions24 marksFree, no account
Question 1
1 mark

Which of the following terms best describes the process of hiding the internal details of a class and only exposing the necessary functionality through public methods?

Question 2
1 mark

In Object-Oriented Programming, the concept of encapsulation is often implemented using access modifiers. Which of the following best describes the implication of using the protected modifier for a class member variable?

Question 3
1 mark

In the context of the IB Computer Science syllabus, why is the use of interfaces preferred over multiple inheritance of concrete classes in languages like Java?

Question 4
1 mark

In Object-Oriented Programming, what is the primary purpose of using a constructor?

Question 5
1 mark

In a Unified Modeling Language (UML) class diagram, an open diamond shape on a line connecting two classes represents aggregation. What does this indicate about the relationship between the objects?

Question 6
2 marks

In a Unified Modeling Language (UML) class diagram, what is the significance of a minus sign (-) appearing before an attribute or method name?

Write your answer out first, then check it against the worked solution.

Question 7
3 marks

In Object-Oriented Programming, explain the purpose of a constructor and specify when it is automatically invoked during the execution of a program.

Write your answer out first, then check it against the worked solution.

Question 8
5 marks

Discuss the impact of modularity on the maintenance phase of the software life cycle, particularly how it reduces the risk of side effects when a single class is updated.

Write your answer out first, then check it against the worked solution.

Question 9
4 marks

Explain the concept of encapsulation in Object-Oriented Programming (OOP) and describe how it is implemented using private access modifiers and public accessor/mutator methods.

Write your answer out first, then check it against the worked solution.

Question 10
5 marks

In the context of inheritance, explain the mechanism of method overriding. Your response should include:
(a) The relationship required between two classes for overriding to occur.
(b) How the super keyword can be used within an overridden method.
(c) Why overriding is considered a form of polymorphism.

Write your answer out first, then check it against the worked solution.

* The content provided by thinka is generated by AI and may not always be accurate or up-to-date. Please use it as a supplementary resource and verify with official materials.

You've seen the model answer. Now get yours marked.

This page can show you how a good answer looks. It cannot tell you what your answer was missing. thinka marks your written work against the real mark scheme in about 15 seconds.

Want more questions like these? Get a fresh set on this topic, graded as you go.

Practice More