(SEM VI) THEORY EXAMINATION 2023-24 OBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING – KOE064
Section-wise Important Questions & Ready Answers
SECTION A
(Attempt all questions in brief – 2 marks each)
(a) Aggregation and Composition
Aggregation and composition represent has-a relationships between classes. Aggregation is a weak association where objects can exist independently, such as a department and teachers. Composition is a strong association where the lifetime of the part depends on the whole, such as a house and its rooms.
(b) Encapsulation with Example
Encapsulation is the process of wrapping data and functions into a single unit called a class and restricting direct access to data. For example, in a BankAccount class, account balance is kept private and accessed only through public methods like deposit() and withdraw().
(c) Generosity (Generality / Generalization)
Generality refers to the process of extracting common characteristics from multiple classes and creating a generalized superclass. It helps reduce redundancy and promotes reuse.
(d) Importance of Modeling and Its Principles
Modeling helps visualize, understand, and manage complex software systems before implementation. Principles of modeling include abstraction, simplicity, consistency, and accuracy to represent real-world systems effectively.
(e) Two Procedure-Oriented Programming Languages
Examples of procedure-oriented programming languages are C and Pascal.
(f) Features of Object-Oriented Programming
OOP features include classes and objects, encapsulation, data abstraction, inheritance, polymorphism, and dynamic binding, which improve modularity and reusability.
(g) C++ Program to Check Prime Number
#include <iostream> using namespace std; int main() { int n, i, flag = 0; cin >> n; for(i = 2; i <= n/2; i++) { if(n % i == 0) { flag = 1; break; } } if(flag == 0 && n > 1) cout << "Prime Number"; else cout << "Not Prime"; return 0; }
(h) Use of typedef
typedef is used to create an alias name for an existing data type, making programs easier to read and maintain.
(i) Three Access Specifiers
The three access specifiers in C++ are private, protected, and public, which control the visibility of class members.
(j) Default Access Modifier in C++
By default, the access modifier used in a C++ class is private.
SECTION B
(Attempt any three – 10 marks each)
2(a) Importance of Modeling and Its Principles
Modeling is important because it helps in visualizing system structure, behavior, and interactions before coding. It reduces complexity, improves communication among stakeholders, and minimizes errors. Principles of modeling include abstraction to focus on essential details, consistency across models, simplicity for clarity, and correctness to accurately represent the system.
2(b) Activity Diagram vs Sequence Diagram
An activity diagram represents the flow of activities and decisions in a system, focusing on control flow. A sequence diagram represents interaction among objects over time, showing message flow. Activity diagrams are useful for workflow modeling, while sequence diagrams are ideal for object interaction analysis.
2(c) Procedural vs Object-Oriented Programming
Procedural programming focuses on functions and procedures, while OOP focuses on objects and classes. OOP supports data hiding, reuse, and flexibility through inheritance and polymorphism, whereas procedural programming has limited reuse and security.
2(d) Polymorphism Program & Macros vs Inline Functions
Polymorphism Example:
class Shape { public: virtual void draw() { cout << "Drawing Shape"; } }; class Circle : public Shape { public: void draw() { cout << "Drawing Circle"; } };
Macros are preprocessor directives without type checking, while inline functions are actual functions with type safety and better debugging support.
2(e) Namespace and Enum in C++
Namespace avoids name conflicts by grouping identifiers. The enum keyword is used to define a set of named integer constants, improving code readability and safety.
SECTION C
3(a) Data Abstraction vs Encapsulation
Data abstraction focuses on exposing only essential features while hiding implementation details. Encapsulation focuses on bundling data and methods together and controlling access. Abstraction deals with what an object does, while encapsulation deals with how it does it.
3(b) UML Diagrams and Their Types
UML diagrams include class diagrams, use case diagrams, sequence diagrams, activity diagrams, state machine diagrams, and deployment diagrams. Each diagram provides a different perspective of system design.
4(a) Use Case Diagram for Restaurant
A restaurant use case diagram includes actors like Customer, Waiter, and Manager interacting with use cases such as placing order, billing, and food preparation.
4(b) State Machine Diagram for Cricket Match
States include start match, batting, bowling, break, and end match. Transitions occur based on events such as innings change or match completion.
Related Notes
BASIC ELECTRICAL ENGINEERING
ENGINEERING PHYSICS THEORY EXAMINATION 2024-25
(SEM I) ENGINEERING CHEMISTRY THEORY EXAMINATION...
THEORY EXAMINATION 2024-25 ENGINEERING MATHEMATICS...
(SEM I) THEORY EXAMINATION 2024-25 ENGINEERING CHE...
(SEM I) THEORY EXAMINATION 2024-25 ENVIRONMENT AND...
Need more notes?
Return to the notes store to keep exploring curated study material.
Back to Notes StoreLatest Blog Posts
Best Home Tutors for Class 12 Science in Dwarka, Delhi
Top Universities in Chennai for Postgraduate Courses with Complete Guide
Best Home Tuition for Competitive Exams in Dwarka, Delhi
Best Online Tutors for Maths in Noida 2026
Best Coaching Centers for UPSC in Rajender Place, Delhi 2026
How to Apply for NEET in Gurugram, Haryana for 2026
Admission Process for BTech at NIT Warangal 2026
Best Home Tutors for JEE in Maharashtra 2026
Meet Our Exceptional Teachers
Discover passionate educators who inspire, motivate, and transform learning experiences with their expertise and dedication
Explore Tutors In Your Location
Discover expert tutors in popular areas across India
Discover Elite Educational Institutes
Connect with top-tier educational institutions offering world-class learning experiences, expert faculty, and innovative teaching methodologies