Plus Two Computer Science Notes Chapter 2 Concepts of Object-Oriented Programming

Kerala State Board New Syllabus Plus Two Computer Science Notes Chapter 2 Concepts of Object-Oriented Programming.

Kerala Plus Two Computer Science Notes Chapter 2 Concepts of Object-Oriented Programming

  • The organizing principle of a program is referred to as paradigm:
  • A program in procedural language consists of a list of Instructions.

Following are the main reasons for increasing the procedural language complexity.

a) Data is undervalued: Here the importance is on doing things rather than the data. The data I have the least importance. That is, data is enclosed to all and there is a chance to access or destroy this data accidentally or intentionally by many functions on a program.

b) Adding new data requires modifications to all / many functions: A program may contain many functions and these functions may access different data used in different locations. If we add new data items, we will need to modify all the functions that access the data. This is a laborious task.

c) Creating new data types is difficult: In procedural languages, some built-in data types such as int, float, double and character are available. Extensibility is the ability to create new data types without major rewriting of codes in its basic, architecture. Some programming languages are extensible but procedural languages are not extensible.

d) Provides poor real-world modeling: Procedural programming paradigm treats data and functions are different hot a single unit. In this Real-life simulations are not possible.

Object-Oriented Programming (OOP) paradigm We see that there are many drawbacks in Procedural Programming Paradigm, OOP eliminates these problems. It wraps data and functions into a single unit. Such units are called objects.

Advantages of using OOP are:

  • OOP allows modularity(divide the large programs into smaller ones)
  • It is good for defining abstract data types.
  • It allows data abstraction. That is it hides or protects data.
  • It allows code reusability
  • Real-life entities can be easily created 0 It supports to create new data types.

Basic concepts of OOP

1) Objects: Objects are real-world entities with similar attributes(properties) and behavior. An object combines data and functions as a single unit. The functions inside the object is called member functions and data is called a member. Example: student, car, chair etc.

2) Classes: A class is a collection of objects with similar attributes. An object is an instance of the class.
Eg. Automobile class, Furniture class etc.

A class declared using the keyword class. Class is considered as the blueprint to create objects. A structure consists of only specifications regarding data but a class consists of specifications regarding both data and functions.

  • Passing message: Calling the member function of an object from another object is called a passing message.
  • Every object will have data structures called at-tributes and behaviors called operations.
  • The object with same data structure (attributes or characteristics) and operations (behavior) are grouped into a class.
  • Data abstraction refers to the act of representing essential features without including the background details.
  • Encapsulation is the mechanism that associates the code and the data it manipulates and keeps them safe from external interference and misuse.
  • The data types created by data abstraction is known as Abstract Data type(ADT).
  • Inheritance is the capability of one class of things to inherit properties from another class.
  • Polymorphism is the ability for a message or data to be processed in more than one form. This is achieved by function overloading, operator overloading, and dynamic binding.

There are two types of polymorphism
a) Compile time(early binding/static) polymorphism: It is the ability of the compiler to relate or bind a function call with the function definition during compilation time itself. Examples are Function overloading and operator overloading

Function overloading: Functions with the same name and different signatures(the number of parameters or data types are different).

Operator overloading: It gives new meaning to an existing C++ operator.

Eg: we know that + is used to add two numbers, Operator overloading assigns + to a new job such as it concatenates two strings into one string,

b) Run time (late binding/dynamic) polymorphism: It is the ability of the compiler to relate or bind a function call with the function definition during run time. It uses the concept of pointers and inheritance.

  • Modularity is the property of a system that has been decomposed into a set of unified and loosely coupled modules.