Grade 12 : Computer Science Chapter 5 (OOP)
Unit-5- Object Oriented Programming (OOP) 5.1 Programming paradigms: procedural, structural and object oriented 5.2 Features of OOP: Class, Object, Polymorphism and Inheritance 5.3 Advantages of OOP 5.4 Application of OOP
UNIT 5: Object Oriented Programming
1. What are the programming methods or approaches of program development?
There are two approaches of program development:
-
Procedure Oriented Programming (POP) – a conventional programming method.
-
Object-Oriented Programming (OOP) – a modern programming approach.
2. What is Procedure Oriented Programming?
It is a conventional method of programming in which a program is divided into many small parts and combined together.
-
In this approach, functions are created and data is not prioritized.
-
Variables are created for data handling and can be global or local:
-
Local variable: Created inside sub-programs.
-
Global variable: Created in the main module and accessible from any module.
-
-
Data alteration is very high in this method.
3. What are the features of Procedure Oriented Programming?
-
A large program is broken down into smaller programs or procedures.
-
Focus is on functions rather than data.
-
Variables are categorized as local and global.
-
High possibility of data alteration (main disadvantage).
-
Follows a top-down approach.
4. What is Object Oriented Programming?
OOP is a modern programming approach where:
-
Real-world entities are treated as objects.
-
Objects are collected into classes, and classes may be controlled by superclasses.
-
Inheritance allows changes in a superclass to be passed to its subclasses.
-
Data is given high priority compared to functions, and data hiding reduces the risk of accidental alteration.
5. What are the characteristics of OOP?
-
Emphasis is on data.
-
Programs are divided into objects.
-
Functions and data are tied together in a single unit.
-
Data hiding prevents accidental alteration.
-
Follows a bottom-up approach.
6. Differences between Procedure Oriented and Object Oriented Programming
| Procedure Oriented | Object Oriented |
|---|---|
| 1. Emphasis on procedures. | 1. Emphasis on data. |
| 2. Programs divided into modules. | 2. Programs divided into objects. |
| 3. Follows top-down method. | 3. Follows bottom-up method. |
| 4. Data cannot be easily hidden. | 4. Data can be hidden. |
| 5. Does not model the real world perfectly. | 5. Models the real world perfectly. |
| 6. Maintenance is difficult. | 6. Maintenance is easy. |
| 7. Code reusability is difficult. | 7. Code reusability is easy. |
| 8. Examples: FORTRAN, COBOL, Pascal, C. | 8. Examples: C++, Java, Smalltalk. |
7. Write short notes on the following:
a) Object
Entities in OOP are called objects (e.g., people, teachers, students, books, cars).
-
Attributes: Characteristics like color, size, weight.
-
Behavior/Functions: Actions like move, turn.
b) Class
A user-defined data type that defines the data types and functions of objects under it.
-
Example: A class Vehicle can have objects like car, bus, truck.
c) Abstraction
Hiding internal details of an object and exposing only the interface.
-
Increases data security and reduces complexity.
d) Encapsulation
Combining data and functions together in a single unit.
-
Prevents unrelated functions from accessing unnecessary data.
e) Inheritance
Creating new classes (subclasses) based on an existing superclass.
-
Enables code reuse and models real-world relationships.
f) Polymorphism
The ability to use the same operator or function in different ways.
-
Example:
+can be used for both arithmetic and string concatenation.
8. What are the advantages and disadvantages of OOP?
Advantages:
-
Code repetition is reduced (via inheritance).
-
Data hiding ensures security.
-
Existing classes can serve as libraries.
-
Easier software development and maintenance.
-
Models real-world systems effectively.
-
Code reusability is improved.
Disadvantages:
-
High compiler and runtime overhead.
-
Requires object-oriented thinking and software engineering expertise.
-
Useful mainly for large and complex projects.
Applications of OOP
-
Expert Systems
-
Artificial Intelligence (AI)
-
Management Information Systems (MIS)
-
Decision Support Systems
-
Computer-based Training & Education
-
Object-Oriented Databases
-
Computer Games
-
Mobile Applications
-
Internet-based Applications
-
User Interface Design
-
Security Systems