Previous year paper

(SEM VI) THEORY EXAMINATION 2023-24 OBJECT ORIENTED PROGRAMMING

Engineering B.Tech 0 downloads

About this previous year paper

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.

TypePrevious year paper
SubjectEngineering
Board / courseB.Tech
FilePDF · 146.23 KB
Shared by SuGanta International

Added by the SuGanta team.