🇵🇰 CSS Computer Science · subject
CSS Computer Science Object Oriented Programming Syllabus
The Object Oriented Programming syllabus for CSS Computer Science in full: 4 chapters and 14 topics, every one listed below, plus 52 Object Oriented Programming flashcards with answers.
Object Oriented Programming syllabus: all 4 chapters
Expand any chapter to see its topics and sub-topics.
-
OOP Concepts & Abstraction
3 topics- Procedural vs Object Oriented Paradigm
- Data Abstraction & Encapsulation
- Classes & Objects
-
Class Design Features
4 topics- Friend Functions
- Static Members
- Composition & Aggregation
- Operator Overloading
-
Inheritance & Polymorphism
4 topics- Single & Multiple Inheritance
- Protected Members & Method Overriding
- Virtual & Pure Virtual Functions
- Abstract Classes
-
Templates, Files & Exceptions
3 topics- Standard Template Library (STL)
- File Streams
- Exception Handling
CSS Computer Science Object Oriented Programming flashcards — 52 questions with answers
What is the procedural programming paradigm?
A programming style that structures a program as a sequence of procedures/functions operating on data. The program is decomposed into functions, and data is typically global or passed around, with emphasis on the logic of actions rather than on data.
In what fundamental way does the object-oriented paradigm differ from the procedural paradigm in handling data and functions?
OOP bundles data and the functions that operate on it together into objects (data + methods), whereas procedural programming keeps data and functions separate, with functions acting on externally held data.
List the four pillars (core principles) of object-oriented programming.
Encapsulation, Abstraction, Inheritance, and Polymorphism.
In procedural vs OOP, how does each typically approach a problem (top-down vs bottom-up)?
Procedural programming uses a top-down approach (break the problem into functions); OOP uses a bottom-up approach (build objects/classes and compose them into a system).
Why is OOP generally considered more secure than procedural programming regarding data?
Because OOP uses encapsulation and access specifiers to hide data inside objects, restricting direct access; procedural programs often rely on global data accessible from anywhere, which is less secure.
Define data abstraction in OOP.
Data abstraction is the principle of exposing only the essential features/operations of an object to the outside world while hiding the internal implementation details.
Define encapsulation in OOP.
Encapsulation is the bundling of data (attributes) and the methods that operate on that data into a single unit (a class), often combined with restricting direct access to the data through access specifiers.
What is the key distinction between abstraction and encapsulation?
Abstraction focuses on hiding complexity by showing only essential features (a design-level concept of 'what'), while encapsulation focuses on bundling data and methods together and restricting access (an implementation-level concept of 'how' data is protected).
How is data hiding typically achieved in a C++ class?
By declaring data members as private (or protected) so they cannot be accessed directly from outside the class, and providing public getter/setter methods for controlled access.
What is a class in OOP?
A class is a user-defined data type that serves as a blueprint or template defining the attributes (data members) and behaviors (member functions) common to a category of objects.
What is an object in OOP?
An object is an instance of a class; it is a concrete entity that occupies memory and has its own copy of the class's data members, with access to the class's member functions.
What are the three access specifiers in a C++ class and their visibility?
public (accessible from anywhere), private (accessible only within the class and its friends), and protected (accessible within the class, its friends, and derived classes).
In C++, what is the default access specifier for members of a class versus a struct?
Members of a class are private by default; members of a struct are public by default.
What is a constructor and when is it called?
A constructor is a special member function with the same name as the class and no return type, automatically called when an object is created, used to initialize the object's data members.
What is a destructor and what symbol denotes it?
A destructor is a special member function automatically called when an object is destroyed (goes out of scope or is deleted), used to release resources. It has the same name as the class preceded by a tilde (~), e.g., ~ClassName().
What is a friend function in C++?
A friend function is a non-member function (declared with the friend keyword inside a class) that is granted access to the private and protected members of that class.
Does a friend function belong to the class, and is it called using an object?
No. A friend function is not a member of the class and is called like an ordinary function (without an object and the dot operator), though it can access the class's private/protected members.
State three key properties/restrictions of friend functions in C++.
1) Friendship is not inherited. 2) Friendship is not mutual/reciprocal unless explicitly declared both ways. 3) A friend function is not called with an object and has no 'this' pointer; it must be granted friendship by the class itself.
What is a friend class?
A friend class is a class whose member functions are all granted access to the private and protected members of another class that declares it as a friend.
What is a static data member of a class?
A static data member is a single shared variable common to all objects of the class; only one copy exists regardless of the number of objects, and it belongs to the class rather than to any individual object.
Show the other 32 Object Oriented Programming flashcards
How must a static data member be defined, and what is its default initial value?
A static data member must be defined (allocated storage) outside the class using the scope resolution operator, e.g., int ClassName::count = 0;. If not explicitly initialized, it defaults to zero.
What is a static member function and what key restriction does it have?
A static member function belongs to the class and can be called without any object (using the class name). Its key restriction is that it can access only static data members and other static functions; it has no 'this' pointer and cannot access non-static members.
Give a common practical use of a static data member.
Counting the number of objects (instances) currently created of a class, since all objects share the same counter.
What is composition in OOP?
Composition is a 'has-a' relationship where one class contains an object of another class as a member, and the contained object's lifetime is fully owned by and dependent on the containing object (strong ownership).
What is aggregation in OOP?
Aggregation is a 'has-a' relationship where one class contains a reference to another object, but the contained object can exist independently of the container (weak ownership / shared lifetime).
State the key difference between composition and aggregation regarding object lifetime.
In composition, the part cannot exist without the whole (if the container is destroyed, the part is destroyed too). In aggregation, the part can exist independently of the whole.
Give a real-world example illustrating composition versus aggregation.
Composition: a House and its Rooms (rooms cannot exist without the house). Aggregation: a Department and its Professors (professors can exist independently of any one department).
What is operator overloading?
Operator overloading is a form of compile-time polymorphism that allows existing operators (like +, -, ==) to be given additional, user-defined meanings when applied to objects of a class.
What is the general syntax of an operator overloading function in C++?
It uses the keyword 'operator' followed by the operator symbol, e.g., returnType operator+(parameters). It can be a member function or a friend/non-member function.
Name at least four operators in C++ that cannot be overloaded.
The scope resolution operator (::), the member access/dot operator (.), the pointer-to-member operator (.*), the ternary conditional operator (?:), and sizeof.
When overloading a unary operator as a member function, how many explicit arguments does it take?
Zero explicit arguments — the single operand is the invoking object (accessed via the 'this' pointer).
When overloading a binary operator as a member function, how many explicit arguments does it take?
One explicit argument — the left operand is the invoking object and the right operand is passed as the parameter.
How are the prefix and postfix increment operators distinguished when overloading?
The postfix version is given a dummy int parameter, e.g., operator++(int), while the prefix version takes no parameter, e.g., operator++().
What is inheritance in OOP?
Inheritance is a mechanism by which a new class (derived/child) acquires the properties and behaviors (members) of an existing class (base/parent), promoting code reuse and establishing an 'is-a' relationship.
What is single inheritance?
Single inheritance is when a derived class inherits from exactly one base class.
What is multiple inheritance?
Multiple inheritance is when a derived class inherits from more than one base class simultaneously.
What is the diamond problem in multiple inheritance?
The diamond problem is an ambiguity that arises when a class inherits from two classes that both derive from a common base class, causing duplicate copies of the base members and ambiguity about which copy to use.
How is the diamond problem resolved in C++?
By using virtual inheritance (declaring the common base as a virtual base class), so that only a single shared copy of the base class subobject exists in the derived class.
In C++, what does the access specifier in 'class B : public A' control?
It controls the access level of inherited members in the derived class. With public inheritance, public members of A stay public and protected stay protected; with private inheritance, all become private; with protected inheritance, public and protected become protected.
What is the purpose of the 'protected' access specifier in the context of inheritance?
Protected members are hidden from outside (non-member) code like private members, but unlike private members they remain accessible to derived classes, enabling controlled inheritance of internal data.
What is method (function) overriding?
Method overriding is when a derived class provides its own implementation of a function that is already defined in its base class, using the same name, return type, and parameters (signature).
What is the difference between method overriding and method overloading?
Overriding redefines an inherited base-class method in a derived class with the same signature (runtime polymorphism, across classes). Overloading defines multiple methods with the same name but different parameter lists within the same scope (compile-time polymorphism).
What is a virtual function in C++?
A virtual function is a member function declared with the keyword 'virtual' in a base class, meant to be overridden in derived classes, enabling runtime (dynamic) polymorphism through base-class pointers or references.
What mechanism enables runtime polymorphism with virtual functions?
Dynamic binding (late binding), typically implemented via a virtual function table (vtable) and a vtable pointer, so the correct overridden function is selected at run time based on the actual object type.
What is a pure virtual function and how is it declared?
A pure virtual function is a virtual function with no implementation in the base class, declared by assigning 0, e.g., virtual void draw() = 0;. It must be overridden by any concrete derived class.
What is an abstract class in C++?
An abstract class is a class that contains at least one pure virtual function. It serves as an interface/base for derived classes and cannot be instantiated directly.
Can you create an object of an abstract class? Can you create a pointer to it?
You cannot create (instantiate) an object of an abstract class, but you can create a pointer or reference to it, which can point to objects of its concrete derived classes.
What happens if a derived class does not override all inherited pure virtual functions?
The derived class itself remains abstract and cannot be instantiated until all pure virtual functions are overridden with concrete implementations.
Why should a base class with virtual functions have a virtual destructor?
To ensure that when an object is deleted through a base-class pointer, the correct derived-class destructor is called, preventing resource leaks and undefined behavior.
What is the Standard Template Library (STL) in C++?
The STL is a library of generic, template-based C++ classes and functions providing reusable data structures and algorithms, primarily organized into containers, iterators, and algorithms (plus function objects).
What are the three main components of the STL?
Containers (data structures like vector, list, map), Algorithms (operations like sort, find, count), and Iterators (objects that traverse and connect containers to algorithms).
Distinguish between STL sequence containers and associative containers, giving examples of each.
Sequence containers store elements in a linear order with positional access (e.g., vector, list, deque); associative containers store elements sorted by key for fast key-based lookup (e.g., set, map, multiset, multimap).
CSS Computer Science Object Oriented Programming FAQ
What is in the CSS Computer Science Object Oriented Programming syllabus?
CSS Computer Science Object Oriented Programming is split into 4 chapters: OOP Concepts & Abstraction, Class Design Features, Inheritance & Polymorphism and Templates, Files & Exceptions. Together they contain 14 topics.
How many chapters are in CSS Computer Science Object Oriented Programming?
4 chapters, containing 14 topics. The largest chapter is Class Design Features, with 4 topics.
Are there flashcards for CSS Computer Science Object Oriented Programming?
Yes — a 52-card Object Oriented Programming deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.