GoConqr has a new look! Let us know what you think.

Notes

Object Oriented Programming

Vineeth Damodar Information Technology English 1 page

Content of the notes (1)

Page 1

OOPS is a programming model that allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects.

Object

An object is a real world entity having attributes (data type) and behaviors (functions). It is an instance of class. When an object is created using the new operator, memory is allocated for the class in the heap, the object is called an instance of class and its starting address will be stored in the object in stack memory. When an object contains null, then it is not possible to access the members of the class using that object.

To create object

Student objectStudent = new Student();

Student - class name.

Class

A class is a collection of objects and represents description of objects that share same attributes and actions. A class will not occupy any memory space and hence it is only a logical representation of data. Class is composed of three things: a name, attributes, and operations.

To create class

public class student

{

}

Abstraction

Data abstraction is a mechanism to provide the essential features without describing the background details.

Eg:

A laptop contains processor, motherboard, RAM etc., To use it we don't need to know how they are all works. We just need to know how to turn on and operate it. So this laptop is an object that is designed to hide its complexity.

Encapsulation

Encapsulation is a mechanism that binds the data member & member function into a single unit called Class. It is a technique used to protect the information in an object. To implement encapsulation we use Access modifiers

1. Private - Only class members have the access.

2. Protected - Class members and derived class members have the access.

3. Public - All members in all classes and project have access.

4. Internal - Only members in the current project have access.

5. Protected internal - All the members in the current project and all the derived classes outside the project have access.

Abstraction VS

1. Abstraction solves the problem at the design level.

2. Abstraction hides unwanted data and provides relevant data.

3. Abstraction lets you focus on what the object does instead of how it does it

4. Abstraction: Outer layout, used in terms of design.

For example:

An external of a Mobile Phone, like it has a display screen and keypad buttons to dial a number.

Encapsulation

1. Encapsulation solves the problem in the implementation level.

2. Encapsulation means hiding the code and data into a single unit to protect the data from the outside world.

3. Encapsulation means hiding the internal details or mechanics of how an object does something.

4. Encapsulation- Inner layout, used in terms of implementation.For example: the internal details of a Mobile Phone, how the keypad button and display screen are connected with each other using circuits.

Polymorphism

The ability of a programming

language to process objects in different ways depending on their data type or

class is known as Polymorphism. Same function applied on different objects gives different results. It enhance ease of use. There are two types of polymorphism

Compile time polymorphism. Best

example is Overloading

Runtime polymorphism. Best

example is Overriding

It enables us invoke derived

class methods using a base class reference variable at run time. In the base class method is

declared as virtual and in the derived

class we override the same method.Virtual keyword indicates method can be override in any derived classes.

Abstract Class

An abstract class is incomplete

and hence cannot be instantiated.It can only be used as base class

and it contains abstract members (Not mandatory).

If a class inherited from

abstract class then it must provide Implementation for all abstract methods or

act itself as a abstract class.

Partial

Class

Partial class

allow us to split a class into 2 or more files. All these parts are then

combined into a single class, when the application is compiled.

The main advantage is that VS uses it to

separate automatically generated system code from developers code. Eg : Aspx.cs and aspx.designer.cs

Allow multiple programmers to work

simultaneously.

Overloading

It allows a class to have

multiple methods with the same name but

with different signature (based on number,type and kind of value). We can not overload a method

based on difference in return type or params keyword.

Overriding

We have a parent class with a virtual function which are overridden by functions in the child classes.

Advantages of OOP

Through inheritance, we can

eliminate redundant code and extend the use of existing classes.

The principle of data hiding helps the programmer to build secure programs

that cannot be invaded by code in other parts of the program.

It is possible to have

multiple instances of an object to co-exist without any interference.

It is easy to partition the

work in a project based on objects.

The data-centered design

approach enables us to capture more details of a model in implementable form.

Object-oriented systems can be

easily upgraded from small to large systems.

Information

Description
Information Technology Note on Object Oriented Programming , created by Vineeth Damodar on 08/03/2017.
Created by
Vineeth Damodar · Mar 2017
Updated
Mar 21, 2017
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?