How unit 1 is examined
This unit covers OOP basics, POP versus OOP, features with merits and demerits, the object model (ATM, hospital, OMT models) and C++ file I/O; the comparison, features and object model topics carry the marks.
Introduction to Object Oriented Thinking & Object Oriented Programming
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Low weight</span>
Definition. <mark>Object Oriented Programming is a paradigm that organises a program as a set of objects, each bundling data (attributes) and the functions (behaviour) that act on that data, and lets objects interact by passing messages.</mark>
Key points.
- Object oriented thinking models the real world: every entity (student, account, ATM) becomes an object with state and behaviour.
- A class is the blueprint and an object is its instance; encapsulation, abstraction, inheritance and polymorphism are the four core concepts.
- Its advantages are reusability through inheritance, easy maintenance, data security through hiding, and extensibility.
- Example: class
Accountholdsbalanceanddeposit();a1anda2are two objects of it.
Asked: [7 marks] (Jun 2020) What do you understand by object oriented programming? What are the advantages of programming using object oriented? Explain and define various OOP concepts in brief.
Comparison with Procedural Programming
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">High weight</span>
Definition. <mark>Procedural (procedure-oriented) programming divides a program into functions that operate on shared data, whereas object oriented programming divides it into objects that combine data and functions and hide the data.</mark> C is procedural; C++ and Java are object oriented.
Key points.
- POP puts the focus on functions (the steps), while OOP puts the focus on data, held inside objects.
- POP follows a top-down approach, breaking a problem into functions; OOP follows a bottom-up approach, building objects first and combining them.
- In POP most data is global and any function can change it, so security is weak; OOP hides data with access specifiers.
- Reuse in POP is by calling functions or copying code; OOP reuses code through inheritance and polymorphism.
- Adding data in POP forces changes in many functions, whereas OOP localises the change inside a class.
| Basis | Procedural (POP) | Object oriented (OOP) |
|---|---|---|
| Focus | Functions and procedures | Data and objects |
| Approach | Top-down | Bottom-up |
| Data security | Global data, no hiding | Data hiding via private/protected |
| Reusability | Functions only | Inheritance, templates |
| Units of program | Functions | Classes and objects |
| Extension | Difficult, edits many functions | Easy, add or derive a class |
| Examples | C, Pascal, FORTRAN | C++, Java, Smalltalk |
Answer frame. Open with the two definitions; draw the seven-row table above; add a closing line that OOP suits large, changing systems while POP suits small, simple programs. When merits and demerits are also asked, follow the table with the next topic.
Pitfall: Writing "OOP is bottom-up, POP is top-down" the wrong way round loses the mark.
Asked: [7 marks] (Jun 2023, Dec 2023, Dec 2025) How is procedure oriented programming different from object oriented programming? / Compare procedural programming with object oriented programming. Asked: [7 marks] (Nov 2019) Differentiate between procedure oriented programming and object oriented programming in brief. Asked: [7 marks] (Dec 2020) Compare the object oriented system with procedure oriented system. Asked: [7 marks] (Jun 2020) Explain the difference between procedural and object oriented programming language; what are the merits and demerits of object oriented methodologies? Asked: [7 marks] (Dec 2024) Compare OOP with Procedural Programming (at least three differences); discuss the features of the object oriented paradigm with merits and demerits.
Features of the Object Oriented Paradigm, Merits and Demerits
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">High weight</span>
Definition. <mark>An object oriented language is one built around classes and objects and supporting encapsulation, abstraction, inheritance, polymorphism and dynamic binding.</mark>
Key points (features).
- Class and object: a class is a user-defined type describing attributes and functions; an object is one instance of it.
- Encapsulation wraps data and functions into one unit (the class) and restricts direct access to the data.
- Data abstraction shows only the essential interface and hides implementation details, as a car driver uses the steering wheel without knowing the engine.
- Inheritance lets a derived class acquire the members of a base class, giving reuse and an is-a hierarchy.
- Polymorphism means one name with many forms: compile-time by overloading, run-time by virtual functions.
- Dynamic binding decides at run time which function a call runs; message passing is how objects request services from each other.
Merits.
- Inheritance gives reusability, so tested code is not rewritten.
- Data hiding gives security, since outside code cannot corrupt private data.
- Modularity makes each class independent, easy to develop, test and maintain.
- Real-world entities map directly to objects, so design is natural and easily extended.
- Objects of a program can coexist, and large systems stay manageable.
Demerits.
- The learning curve is steep because concepts such as polymorphism and design patterns take time.
- Programs are larger, and virtual calls and object creation make execution slower.
- Good class design needs careful planning; poor design leads to complexity.
- It is not ideal for small or purely mathematical programs.
Applications. GUI and window systems, simulation and modelling, database systems, games, CAD/CAM, real-time and AI systems, and office automation.
| Merit | Demerit |
|---|---|
| Reuse via inheritance | Steep learning curve |
| Data security | Larger, slower programs |
| Easy maintenance | Needs careful design |
Answer frame. Open with the definition of OOP; list the six features with a one-line example each; then merits, demerits, applications; close that OOP suits large, evolving systems. For "features" only, stop after the features. For "merits and demerits" only, use the table and add the applications line.
Asked: [7 marks] (Nov 2022, Jun 2023, Dec 2023, Dec 2024, Dec 2025) What is OOP? Write merits, demerits and applications; explain features with examples; where OOP is or is not ideal. Asked: [7 marks] (Nov 2018) Write merits and demerits of Object Oriented Methodology. Asked: [7 marks] (May 2019) Explain object oriented programming languages with their features. Asked: [7 marks] (Dec 2020) State the important features of object oriented programming.
Object Model
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">High weight</span>
Definition. <mark>The object model is the conceptual framework of object orientation: it describes a system as a set of objects and classes with their attributes, operations and relationships, and it is the basis for analysis and design.</mark>
Key points.
- Its seven principles are abstraction, encapsulation, modularity, hierarchy (the first four are major), then typing, concurrency and persistence (minor).
- Abstraction picks the essential features of an entity; encapsulation hides its internals behind an interface.
- Modularity splits the system into cohesive, loosely coupled classes; hierarchy ranks them by is-a (inheritance) and part-of (aggregation).
- Typing enforces that objects of the wrong class are not mixed; concurrency lets objects run in parallel; persistence keeps objects alive after the program ends.
- Role: it identifies classes, objects, attributes and operations, and guides both analysis and design.
- It is beneficial when a system is large, changing or shared by a team, since it gives a common structure and reusable design; a tiny one-off calculation does not need it.
ATM example. Classes: Customer, Card, ATM (owns CardReader, CashDispenser), Bank, Account, Transaction.
<figure class="ds-fig" style="margin:1.4rem 0;overflow-x:auto"><svg xmlns="http://www.w3.org/2000/svg" id="dsfig-u1-01" viewBox="0 0 424 252" width="424" height="252" role="img" aria-label="ATM object model. Cus = Customer, Bnk = Bank, Acc = Account, Txn = Transaction, Rdr = CardReader (CashDispenser sits with it inside ATM)"><style>#dsfig-u1-01 .e{stroke:#454C5A;stroke-width:1.4;fill:none}#dsfig-u1-01 .e.hi{stroke:#2340B8;stroke-width:2.6}#dsfig-u1-01 .n{fill:#FFFFFF;stroke:#16181D;stroke-width:1.4}#dsfig-u1-01 .n.hi{fill:#E3E9FC;stroke:#2340B8;stroke-width:2.2}#dsfig-u1-01 .n.rb-b{fill:#16181D;stroke:#16181D}#dsfig-u1-01 .n.rb-r{fill:#BD3227;stroke:#BD3227}#dsfig-u1-01 text{font-family:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace;font-size:13px}#dsfig-u1-01 .t{fill:#16181D;font-weight:500}#dsfig-u1-01 .t.inv{fill:#FFFFFF;font-weight:700}#dsfig-u1-01 .kd{stroke:#16181D;stroke-width:1.2}#dsfig-u1-01 .dot{fill:#16181D}#dsfig-u1-01 .ann{fill:#2340B8;font-size:11px;font-weight:700}#dsfig-u1-01 .lbl{fill:#6F7787;font-family:system-ui,-apple-system,sans-serif;font-size:12px;font-weight:700}#dsfig-u1-01 .ptr{fill:#2340B8;font-size:12px;font-weight:700}#dsfig-u1-01 .ah{fill:#454C5A}#dsfig-u1-01 .ah.hi{fill:#2340B8}#dsfig-u1-01 .wl rect{fill:#FFFFFF;stroke:#DCE0E7}#dsfig-u1-01 .wl .t{font-size:12px;font-weight:700}#dsfig-u1-01 .wl.hi rect{fill:#2340B8;stroke:#2340B8}#dsfig-u1-01 .wl.hi .t{fill:#FFFFFF}html.dark #dsfig-u1-01 .e{stroke:#B1B7C3}html.dark #dsfig-u1-01 .e.hi{stroke:#8FA3FF}html.dark #dsfig-u1-01 .n{fill:#161920;stroke:#E6E8ED}html.dark #dsfig-u1-01 .n.hi{fill:#1E2748;stroke:#8FA3FF}html.dark #dsfig-u1-01 .n.rb-b{fill:#E6E8ED;stroke:#E6E8ED}html.dark #dsfig-u1-01 .n.rb-r{fill:#FF7E71;stroke:#FF7E71}html.dark #dsfig-u1-01 .t{fill:#E6E8ED}html.dark #dsfig-u1-01 .t.inv{fill:#0F1115}html.dark #dsfig-u1-01 .kd{stroke:#E6E8ED}html.dark #dsfig-u1-01 .dot{fill:#E6E8ED}html.dark #dsfig-u1-01 .ann{fill:#8FA3FF}html.dark #dsfig-u1-01 .lbl{fill:#858D9C}html.dark #dsfig-u1-01 .ptr{fill:#8FA3FF}html.dark #dsfig-u1-01 .ah{fill:#B1B7C3}html.dark #dsfig-u1-01 .ah.hi{fill:#8FA3FF}html.dark #dsfig-u1-01 .wl rect{fill:#161920;stroke:#2A2E37}html.dark #dsfig-u1-01 .wl.hi rect{fill:#8FA3FF;stroke:#8FA3FF}html.dark #dsfig-u1-01 .wl.hi .t{fill:#0F1115}</style><defs><marker id="ah1" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah" d="M0,1 L9,5 L0,9 z"/></marker><marker id="ahh1" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah hi" d="M0,1 L9,5 L0,9 z"/></marker></defs><path class="e" d="M59,40 L193,40"/><path class="e" d="M231,40 L365,40"/><path class="e" d="M384,59 L384,193"/><path class="e" d="M231,212 L365,212"/><path class="e" d="M212,59 L212,193"/><path class="e" d="M198.6,53.4 L53.4,198.6"/><g class="wl"><rect x="105.6" y="31" width="40.8" height="18" rx="9"/><text class="t" x="126" y="40" dy=".35em" text-anchor="middle">uses</text></g><g class="wl"><rect x="263.7" y="31" width="68.7" height="18" rx="9"/><text class="t" x="298" y="40" dy=".35em" text-anchor="middle">connects</text></g><g class="wl"><rect x="367.2" y="117" width="33.6" height="18" rx="9"/><text class="t" x="384" y="126" dy=".35em" text-anchor="middle">has</text></g><g class="wl"><rect x="284.8" y="203" width="26.4" height="18" rx="9"/><text class="t" x="298" y="212" dy=".35em" text-anchor="middle">on</text></g><g class="wl"><rect x="188.5" y="117" width="47.1" height="18" rx="9"/><text class="t" x="212" y="126" dy=".35em" text-anchor="middle">makes</text></g><g class="wl"><rect x="109.2" y="117" width="33.6" height="18" rx="9"/><text class="t" x="126" y="126" dy=".35em" text-anchor="middle">has</text></g><circle class="n" cx="40" cy="40" r="18"/><text class="t" x="40" y="40" dy=".35em" text-anchor="middle">Cus</text><circle class="n" cx="212" cy="40" r="18"/><text class="t" x="212" y="40" dy=".35em" text-anchor="middle">ATM</text><circle class="n" cx="384" cy="40" r="18"/><text class="t" x="384" y="40" dy=".35em" text-anchor="middle">Bnk</text><circle class="n" cx="384" cy="212" r="18"/><text class="t" x="384" y="212" dy=".35em" text-anchor="middle">Acc</text><circle class="n" cx="212" cy="212" r="18"/><text class="t" x="212" y="212" dy=".35em" text-anchor="middle">Txn</text><circle class="n" cx="40" cy="212" r="18"/><text class="t" x="40" y="212" dy=".35em" text-anchor="middle">Rdr</text></svg><figcaption style="font-size:.82em;opacity:.72;margin-top:.45rem">ATM object model. Cus = Customer, Bnk = Bank, Acc = Account, Txn = Transaction, Rdr = CardReader (CashDispenser sits with it inside ATM)</figcaption></figure>
- Association: Customer uses ATM; ATM connects to Bank.
- Aggregation: ATM is made of CardReader and CashDispenser; Bank has many Accounts.
- Inheritance: Account is specialised as SavingsAccount and CurrentAccount.
Object diagram, hospital. Objects are instances with values, written name:Class.
<figure class="ds-fig" style="margin:1.4rem 0;overflow-x:auto"><svg xmlns="http://www.w3.org/2000/svg" id="dsfig-u1-02" viewBox="0 0 424 252" width="424" height="252" role="img" aria-label="d1 = Dr Sharma:Doctor, p1 = Amit:Patient, r1 = Room 12:Room, b1 = Rs 5000:Bill, m1 = MedicalRecord"><style>#dsfig-u1-02 .e{stroke:#454C5A;stroke-width:1.4;fill:none}#dsfig-u1-02 .e.hi{stroke:#2340B8;stroke-width:2.6}#dsfig-u1-02 .n{fill:#FFFFFF;stroke:#16181D;stroke-width:1.4}#dsfig-u1-02 .n.hi{fill:#E3E9FC;stroke:#2340B8;stroke-width:2.2}#dsfig-u1-02 .n.rb-b{fill:#16181D;stroke:#16181D}#dsfig-u1-02 .n.rb-r{fill:#BD3227;stroke:#BD3227}#dsfig-u1-02 text{font-family:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace;font-size:13px}#dsfig-u1-02 .t{fill:#16181D;font-weight:500}#dsfig-u1-02 .t.inv{fill:#FFFFFF;font-weight:700}#dsfig-u1-02 .kd{stroke:#16181D;stroke-width:1.2}#dsfig-u1-02 .dot{fill:#16181D}#dsfig-u1-02 .ann{fill:#2340B8;font-size:11px;font-weight:700}#dsfig-u1-02 .lbl{fill:#6F7787;font-family:system-ui,-apple-system,sans-serif;font-size:12px;font-weight:700}#dsfig-u1-02 .ptr{fill:#2340B8;font-size:12px;font-weight:700}#dsfig-u1-02 .ah{fill:#454C5A}#dsfig-u1-02 .ah.hi{fill:#2340B8}#dsfig-u1-02 .wl rect{fill:#FFFFFF;stroke:#DCE0E7}#dsfig-u1-02 .wl .t{font-size:12px;font-weight:700}#dsfig-u1-02 .wl.hi rect{fill:#2340B8;stroke:#2340B8}#dsfig-u1-02 .wl.hi .t{fill:#FFFFFF}html.dark #dsfig-u1-02 .e{stroke:#B1B7C3}html.dark #dsfig-u1-02 .e.hi{stroke:#8FA3FF}html.dark #dsfig-u1-02 .n{fill:#161920;stroke:#E6E8ED}html.dark #dsfig-u1-02 .n.hi{fill:#1E2748;stroke:#8FA3FF}html.dark #dsfig-u1-02 .n.rb-b{fill:#E6E8ED;stroke:#E6E8ED}html.dark #dsfig-u1-02 .n.rb-r{fill:#FF7E71;stroke:#FF7E71}html.dark #dsfig-u1-02 .t{fill:#E6E8ED}html.dark #dsfig-u1-02 .t.inv{fill:#0F1115}html.dark #dsfig-u1-02 .kd{stroke:#E6E8ED}html.dark #dsfig-u1-02 .dot{fill:#E6E8ED}html.dark #dsfig-u1-02 .ann{fill:#8FA3FF}html.dark #dsfig-u1-02 .lbl{fill:#858D9C}html.dark #dsfig-u1-02 .ptr{fill:#8FA3FF}html.dark #dsfig-u1-02 .ah{fill:#B1B7C3}html.dark #dsfig-u1-02 .ah.hi{fill:#8FA3FF}html.dark #dsfig-u1-02 .wl rect{fill:#161920;stroke:#2A2E37}html.dark #dsfig-u1-02 .wl.hi rect{fill:#8FA3FF;stroke:#8FA3FF}html.dark #dsfig-u1-02 .wl.hi .t{fill:#0F1115}</style><defs><marker id="ah2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah" d="M0,1 L9,5 L0,9 z"/></marker><marker id="ahh2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah hi" d="M0,1 L9,5 L0,9 z"/></marker></defs><path class="e" d="M59,40 L193,40"/><path class="e" d="M231,40 L365,40"/><path class="e" d="M212,59 L212,193"/><path class="e" d="M198.6,53.4 L53.4,198.6"/><g class="wl"><rect x="98.9" y="31" width="54.3" height="18" rx="9"/><text class="t" x="126" y="40" dy=".35em" text-anchor="middle">treats</text></g><g class="wl"><rect x="263.7" y="31" width="68.7" height="18" rx="9"/><text class="t" x="298" y="40" dy=".35em" text-anchor="middle">admitted</text></g><g class="wl"><rect x="184.9" y="117" width="54.3" height="18" rx="9"/><text class="t" x="212" y="126" dy=".35em" text-anchor="middle">billed</text></g><g class="wl"><rect x="98.9" y="117" width="54.3" height="18" rx="9"/><text class="t" x="126" y="126" dy=".35em" text-anchor="middle">record</text></g><circle class="n" cx="40" cy="40" r="18"/><text class="t" x="40" y="40" dy=".35em" text-anchor="middle">d1</text><circle class="n" cx="212" cy="40" r="18"/><text class="t" x="212" y="40" dy=".35em" text-anchor="middle">p1</text><circle class="n" cx="384" cy="40" r="18"/><text class="t" x="384" y="40" dy=".35em" text-anchor="middle">r1</text><circle class="n" cx="212" cy="212" r="18"/><text class="t" x="212" y="212" dy=".35em" text-anchor="middle">b1</text><circle class="n" cx="40" cy="212" r="18"/><text class="t" x="40" y="212" dy=".35em" text-anchor="middle">m1</text></svg><figcaption style="font-size:.82em;opacity:.72;margin-top:.45rem">d1 = Dr Sharma:Doctor, p1 = Amit:Patient, r1 = Room 12:Room, b1 = Rs 5000:Bill, m1 = MedicalRecord</figcaption></figure>
Links show that doctor d1 treats patient p1, who occupies room r1, owes bill b1 and has record m1.
Object Modeling Technique (OMT). OMT builds a system from three related models.
| Model | Shows | Diagram |
|---|---|---|
| Object (static) | classes, attributes, associations | class/object diagram |
| Dynamic (control) | states, events, transitions over time | state diagram |
| Functional (data) | how data is transformed | data flow diagram (DFD) |
<figure class="ds-fig" style="margin:1.4rem 0;overflow-x:auto"><svg xmlns="http://www.w3.org/2000/svg" id="dsfig-u1-03" viewBox="0 0 424 80" width="424" height="80" role="img" aria-label="Dynamic model of ATM: Idl = Idle, Pin = Enter PIN, Mnu = Menu"><style>#dsfig-u1-03 .e{stroke:#454C5A;stroke-width:1.4;fill:none}#dsfig-u1-03 .e.hi{stroke:#2340B8;stroke-width:2.6}#dsfig-u1-03 .n{fill:#FFFFFF;stroke:#16181D;stroke-width:1.4}#dsfig-u1-03 .n.hi{fill:#E3E9FC;stroke:#2340B8;stroke-width:2.2}#dsfig-u1-03 .n.rb-b{fill:#16181D;stroke:#16181D}#dsfig-u1-03 .n.rb-r{fill:#BD3227;stroke:#BD3227}#dsfig-u1-03 text{font-family:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace;font-size:13px}#dsfig-u1-03 .t{fill:#16181D;font-weight:500}#dsfig-u1-03 .t.inv{fill:#FFFFFF;font-weight:700}#dsfig-u1-03 .kd{stroke:#16181D;stroke-width:1.2}#dsfig-u1-03 .dot{fill:#16181D}#dsfig-u1-03 .ann{fill:#2340B8;font-size:11px;font-weight:700}#dsfig-u1-03 .lbl{fill:#6F7787;font-family:system-ui,-apple-system,sans-serif;font-size:12px;font-weight:700}#dsfig-u1-03 .ptr{fill:#2340B8;font-size:12px;font-weight:700}#dsfig-u1-03 .ah{fill:#454C5A}#dsfig-u1-03 .ah.hi{fill:#2340B8}#dsfig-u1-03 .wl rect{fill:#FFFFFF;stroke:#DCE0E7}#dsfig-u1-03 .wl .t{font-size:12px;font-weight:700}#dsfig-u1-03 .wl.hi rect{fill:#2340B8;stroke:#2340B8}#dsfig-u1-03 .wl.hi .t{fill:#FFFFFF}html.dark #dsfig-u1-03 .e{stroke:#B1B7C3}html.dark #dsfig-u1-03 .e.hi{stroke:#8FA3FF}html.dark #dsfig-u1-03 .n{fill:#161920;stroke:#E6E8ED}html.dark #dsfig-u1-03 .n.hi{fill:#1E2748;stroke:#8FA3FF}html.dark #dsfig-u1-03 .n.rb-b{fill:#E6E8ED;stroke:#E6E8ED}html.dark #dsfig-u1-03 .n.rb-r{fill:#FF7E71;stroke:#FF7E71}html.dark #dsfig-u1-03 .t{fill:#E6E8ED}html.dark #dsfig-u1-03 .t.inv{fill:#0F1115}html.dark #dsfig-u1-03 .kd{stroke:#E6E8ED}html.dark #dsfig-u1-03 .dot{fill:#E6E8ED}html.dark #dsfig-u1-03 .ann{fill:#8FA3FF}html.dark #dsfig-u1-03 .lbl{fill:#858D9C}html.dark #dsfig-u1-03 .ptr{fill:#8FA3FF}html.dark #dsfig-u1-03 .ah{fill:#B1B7C3}html.dark #dsfig-u1-03 .ah.hi{fill:#8FA3FF}html.dark #dsfig-u1-03 .wl rect{fill:#161920;stroke:#2A2E37}html.dark #dsfig-u1-03 .wl.hi rect{fill:#8FA3FF;stroke:#8FA3FF}html.dark #dsfig-u1-03 .wl.hi .t{fill:#0F1115}</style><defs><marker id="ah3" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah" d="M0,1 L9,5 L0,9 z"/></marker><marker id="ahh3" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah hi" d="M0,1 L9,5 L0,9 z"/></marker></defs><path class="e" d="M59,40 L191,40" marker-end="url(#ah3)"/><path class="e" d="M231,40 L363,40" marker-end="url(#ah3)"/><path class="e" d="M365,40 L61,40" marker-end="url(#ah3)"/><g class="wl"><rect x="105.6" y="31" width="40.8" height="18" rx="9"/><text class="t" x="126" y="40" dy=".35em" text-anchor="middle">card</text></g><g class="wl"><rect x="274.5" y="31" width="47.1" height="18" rx="9"/><text class="t" x="298" y="40" dy=".35em" text-anchor="middle">okpin</text></g><g class="wl"><rect x="188.5" y="31" width="47.1" height="18" rx="9"/><text class="t" x="212" y="40" dy=".35em" text-anchor="middle">eject</text></g><circle class="n" cx="40" cy="40" r="18"/><text class="t" x="40" y="40" dy=".35em" text-anchor="middle">Idl</text><circle class="n" cx="212" cy="40" r="18"/><text class="t" x="212" y="40" dy=".35em" text-anchor="middle">Pin</text><circle class="n" cx="384" cy="40" r="18"/><text class="t" x="384" y="40" dy=".35em" text-anchor="middle">Mnu</text></svg><figcaption style="font-size:.82em;opacity:.72;margin-top:.45rem">Dynamic model of ATM: Idl = Idle, Pin = Enter PIN, Mnu = Menu</figcaption></figure>
Functional model: Customer sends PIN and amount, process "Validate" reads Account, process "Dispense" outputs cash and receipt. The object model gives the classes, the dynamic model gives their behaviour, and the functional model gives the computations; all three are linked because events act on objects and processes use their operations.
Answer frame. For ATM: open with the definition; draw the class diagram; explain association, aggregation, inheritance; close with benefits. For OMT: define OMT, one diagram each for the three models, then their relation. For role/why/when: definition, role in analysis and design, then when useful. For the hospital diagram: draw instances with values and explain each link.
Asked: [7 marks] (Dec 2023, Dec 2025) Explain object model with example of ATM of a bank / Explain object model and basic elements of OOPS. Asked: [7 marks] (Dec 2020) What are models of object modeling techniques? Asked: [7 marks] (Dec 2020) Explain the following models: object, dynamic and functional model. Asked: [7 marks] (Jun 2020) Discuss the role of object model regarding object oriented technology and why and when it is beneficial to design an object model for any task. Asked: [7 marks] (Dec 2023) Draw and explain object diagram for hospital management system. Asked: [14 marks] (Jun 2023) Short note (any two): Ambiguity in multiple inheritance, Object Model, Access specifier in C++ (Object Model part).
Elements of OOPS
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Low weight</span>
Definition. <mark>The elements of OOP are the building blocks every object oriented language supports: object, class, encapsulation, abstraction, inheritance and polymorphism.</mark>
Key points.
- Encapsulation binds data and functions in a class and hides the data.
- Abstraction exposes only what is essential and hides the details.
- Inheritance lets a new class reuse and extend an existing class.
- Polymorphism lets one function name or operator act in different ways.
- Object and class are the base: objects communicate by message passing and are bound dynamically.
Asked: [7 marks] (Nov 2018) What are the main characteristics of Object Oriented Language?
IO Processing
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Medium weight</span>
Definition. <mark>IO processing in C++ is the transfer of data between a program and devices such as keyboard, screen and files through streams, which are sequences of bytes flowing from a source to a destination.</mark>
Key points.
- An input stream (
istream,ifstream) reads data into the program, and an output stream (ostream,ofstream) writes data out of it;fstreamdoes both. <iostream>(iostream.hin old compilers) declarescin,cout,cerrandclog;<fstream>declares file streams;<iomanip>declares formatters likesetw.coutis the predefinedostreamobject attached to the screen, used with the insertion operator<<;cinuses the extraction operator>>.- A file stream object is initialised either by the constructor,
ofstream f("a.txt");, or byf.open("a.txt")after creating it. - File functions:
open(),close(),read(),write(),get(),put(),getline(),seekg(),seekp(),tellg(),tellp(), and status testseof(),fail(),bad(),good().
Example (Emp.dat: create, read, compute net salary, write back; output 33000).
struct Emp { int no; char name[20]; float sal, ded, allow, net; char dept[10]; };
Emp e = {1, "Ravi", 30000, 2000, 5000, 0, "CSE"};
fstream f("Emp.dat", ios::out | ios::binary);
f.write((char*)&e, sizeof e); f.close();
f.open("Emp.dat", ios::in | ios::out | ios::binary);
f.read((char*)&e, sizeof e);
e.net = e.sal + e.allow - e.ded;
f.seekp(0); f.write((char*)&e, sizeof e); // net = 33000
Answer frame. Define streams; list header files; explain cout and cin; give the file-stream example; close with the function list. For the program, write the struct, create, reopen with ios::in | ios::out, compute, seekp and write.
Asked: [7 marks] (Nov 2019) What is meant by initializing file stream objects? What are input and output streams? Give example. Asked: [7 marks] (Jun 2020) What is IO processing? List the I/O library header files, explain iostream.h and the functionality of cout. Asked: [7 marks] (Jun 2023) Program to create Emp.dat with employee fields, read the record, calculate net salary and write it back. Asked: [7 marks] (Jun 2023) What functions do file stream classes support for I/O operations?
Last-minute revision
- OOP = objects combining data and functions, with data hidden.
- POP: function focus, top-down, global data; OOP: data focus, bottom-up, data hiding.
- Four core concepts: encapsulation, abstraction, inheritance, polymorphism.
- Merits: reuse, security, modularity, maintenance. Demerits: steep learning, larger and slower programs.
- Object model principles: abstraction, encapsulation, modularity, hierarchy, typing, concurrency, persistence.
- OMT models: object (static), dynamic (state diagram), functional (DFD).
- ATM classes: ATM, Bank, Account, CardReader, CashDispenser, Customer, Transaction.
- Hospital objects: d1:Doctor, p1:Patient, r1:Room, b1:Bill, rec1:MedicalRecord.
coutuses<<,cinuses>>;ifstreamreads,ofstreamwrites,fstreamboth.- Net salary = salary + allowances - deductions.
Memory hooks
- PIE-A: Polymorphism, Inheritance, Encapsulation, Abstraction.
- POP = "Procedures, Peel top-down"; OOP = "Objects, Own bottom-up".
- Object model minor principles: T-C-P (Typing, Concurrency, Persistence).
- OMT = O-D-F: Object (what), Dynamic (when), Functional (how).
<<points out to the screen,>>points into the variable.
Coverage checklist
- Introduction to Object Oriented Thinking & Object Oriented Programming: Jun 2020 OOP concepts question.
- Comparison with Procedural Programming: Nov 2019, Dec 2020, Jun 2020, Jun/Dec 2023, Dec 2024, Dec 2025 comparisons.
- features of Object oriented paradigm– Merits and demerits of OO methodology: Nov 2018, May 2019, Dec 2020, Nov 2022, Jun 2023, Dec 2023, Dec 2024, Dec 2025.
- Object model: ATM, OMT models, role and benefit, hospital object diagram, Jun 2023 short note.
- Elements of OOPS: Nov 2018 characteristics of OO language.
- IO processing: Nov 2019, Jun 2020, Jun 2023 (program and file functions).