Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ..pptx

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Chargement dans…3
×

Consultez-les par la suite

1 sur 10 Publicité

Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ..pptx

Télécharger pour lire hors ligne

OOP
As the name suggests, Object-Oriented Programming or OOPs refers to languages that use objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism, etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.

OOPs Concepts:

Class
Objects
Data Abstraction
Encapsulation
Inheritance
Polymorphism
Dynamic Binding
Message Passing

1. Class:

A class is a user-defined data type. It consists of data members and member functions, which can be accessed and used by creating an instance of that class. It represents the set of properties or methods that are common to all objects of one type. A class is like a blueprint for an object.


For Example: Consider the Class of Cars. There may be many cars with different names and brands but all of them will share some common properties like all of them will have 4 wheels, Speed Limit, Mileage range, etc. So here, Car is the class, and wheels, speed limits, mileage are their properties.

2. Object:

It is a basic unit of Object-Oriented Programming and represents the real-life entities. An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated. An object has an identity, state, and behavior. Each object contains data and code to manipulate the data. Objects can interact without having to know details of each other’s data or code, it is sufficient to know the type of message accepted and type of response returned by the objects.

For example “Dog” is a real-life Object, which has some characteristics like color, Breed, Bark, Sleep, and Eats.

Object in OOPs
Object

3. Data Abstraction:

Data abstraction is one of the most essential and important features of object-oriented programming. Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation. Consider a real-life example of a man driving a car. The man only knows that pressing the accelerators will increase the speed of the car or applying brakes will stop the car, but he does not know about how on pressing the accelerator the speed is increasing, he does not know about the inner mechanism of the car or the implementation of the accelerator, brakes, etc in the car. This is what abstraction is.

4. Encapsulation:

Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. In Encapsulation, the variables or data of a class are hidden from any other class and can be accessed only through any member function of their class in which they are declared. As in encapsulation, the data in a class is hidden from other classes, so it is also known as data-hiding.

Encapsulation in Object Oriented Pro

OOP
As the name suggests, Object-Oriented Programming or OOPs refers to languages that use objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism, etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.

OOPs Concepts:

Class
Objects
Data Abstraction
Encapsulation
Inheritance
Polymorphism
Dynamic Binding
Message Passing

1. Class:

A class is a user-defined data type. It consists of data members and member functions, which can be accessed and used by creating an instance of that class. It represents the set of properties or methods that are common to all objects of one type. A class is like a blueprint for an object.


For Example: Consider the Class of Cars. There may be many cars with different names and brands but all of them will share some common properties like all of them will have 4 wheels, Speed Limit, Mileage range, etc. So here, Car is the class, and wheels, speed limits, mileage are their properties.

2. Object:

It is a basic unit of Object-Oriented Programming and represents the real-life entities. An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated. An object has an identity, state, and behavior. Each object contains data and code to manipulate the data. Objects can interact without having to know details of each other’s data or code, it is sufficient to know the type of message accepted and type of response returned by the objects.

For example “Dog” is a real-life Object, which has some characteristics like color, Breed, Bark, Sleep, and Eats.

Object in OOPs
Object

3. Data Abstraction:

Data abstraction is one of the most essential and important features of object-oriented programming. Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation. Consider a real-life example of a man driving a car. The man only knows that pressing the accelerators will increase the speed of the car or applying brakes will stop the car, but he does not know about how on pressing the accelerator the speed is increasing, he does not know about the inner mechanism of the car or the implementation of the accelerator, brakes, etc in the car. This is what abstraction is.

4. Encapsulation:

Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. In Encapsulation, the variables or data of a class are hidden from any other class and can be accessed only through any member function of their class in which they are declared. As in encapsulation, the data in a class is hidden from other classes, so it is also known as data-hiding.

Encapsulation in Object Oriented Pro

Publicité
Publicité

Plus De Contenu Connexe

Similaire à Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ..pptx (20)

Plus récents (20)

Publicité

Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ..pptx

  1. 1. Presenting by – SHUVROJIT MAJUMDER (B.tech, CSE) Year - 3rd Year Sem - 5th sem Roll No. – 25900120006 Reg. No. – 202590100110010 Sub – OBJECT ORIENTED PROGRAMMING (OOPS) Sub Code - PCC-CS503
  2. 2. Contents
  3. 3. OOP – “Object Oriented Programming” . This is an engineering approach to build / develop Software System . “Object” means a real-world entity such as a pen, chair, table, computer, etc. ”Object-Oriented Programming” is a methodology or paradigm to design a program using classes and objects. There are some Key-features of the oop Concept . They are ------- 1. Abstraction 2. Inheritance 3. Encapsulation 4. Polymorphism In this presentation we are discussing about the most important three(3) Inheritance , Encapsulation , Polymorphism . INTRODUCTION Basic OOP Concept Key - Features
  4. 4. INHERITANCE  Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object .  The idea behind inheritance in Java is that we can create new classes, - which are built upon existing classes. When we inherit from an existing class, we can re-use methods and fields of the parent class. So that due to inheritance  Code reusability increases .  Inheritance represents the IS-A relationship which is also known as a – parent - child relationship .  Program as example : class Bike{ int wheel = 2; } class SportsBikeextends Bike { int maxSpeed = 180; public static void main(String args[]){ SportsBike ktm = new SportsBike(); System.out.println(“No.ofWheelin ktm is:"+ktm.wheel); System.out.println(“Max Speedof ktm is:"+ktm.maxSpeed+”Km/h”); } } Code No.of Wheel in ktm is : 2 Max Speed of ktm is : 180 Km/h Output
  5. 5.  Terminologies used in Inheritance : Class : A class is a group of objects which have common properties. It is a template or blueprint of objects . Sub Class/Child Class: Subclass is a class which inherits the other class. It is also called a derived class, extended class, or child class. Super Class/Parent Class: Superclass is the class from where a subclass inherits the features. It is also called a base class or a parent class. Reusability : As the name specifies, reusability is a mechanism which facilitates us to reuse the fields & methods of the existing class when we create a new class. Types Of Inheritance :
  6. 6. ENCAPSULATION class Name { private int age; // Private is using to hide the data public int getAge() { returnage; } // getter public void setAge(intage) { this.age = age; } // setter } class GFG { public static void main(String[] args) { Name n1 = new Name(); n1.setAge(19); System.out.println(“Theage of the person is: ”+ n1.getAge()); } } Code The age of the person is : 19 Output  Encapsulation in Java is a process of wrapping code and data together into a single unit, for example, a capsule which is mixed of several medicines.  We can create a fully encapsulated class in Java by making all the data members of the class private. Now we can use setter and getter methods to set and get the data in it.  The Java Bean class is the example of a fully encapsulated class.  Program as example :
  7. 7. Advantages of Encapsulation in Java : By providing only a setter or getter method, we can make the class read-only or write-only. In other words, you can skip the -- getter or setter methods. It provides us the control over the data. Suppose we want to set the value of id which should be greater than 100 only, we can --write the logic inside the setter method . We also can write the logic not to store the negative numbers in the setter methods. It is a way to achieve data hiding in Java because other class will not be able to access the data through the private data members. The encapsulate class is easy to test. So, it is better for unit testing. The standard IDE's are providing the facility to generate the ---getters and setters. So, it is easy and fast to create an encapsulated class in Java.
  8. 8. POLYMORPHISM  Polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form.  Real - life Illustration: Polymorphism : A person at the same time can have different characteristics. Like a man at the same time is a father, a Fruit Buyer, an employee. So the same person possesses different behavior in different situations. This is called polymorphism .  Polymorphism is considered one of the important features of Object-Oriented Programming. Polymorphism allows us to perform a single action in different ways. In other words, polymorphism allows you to define one interface and have multiple implementations. The word --- “poly” means many and “morphs” means forms, So it means many forms.  Polymorphism is the ability of one object to be treated and used like ---- another object. As example, we treat duck as an animal and not just as a duck. Similarly, we treat dog and cat also as animals.
  9. 9. Types of polymorphism : In Java polymorphism is mainly divided into two types: (1) Compile-time Polymorphism /Static Polymorphism –  Overloading  Overriding (2) Runtime Polymorphism / Dynamic Polymorphism – It is also known as Dynamic Method Dispatch. It is a proces in which a function call to the overridden method is resolved at Runtime. This type of polymor --- phism is achieved by Method Overriding . Method overridi on the other hand, occurs when a derived class has a definition for one of the member functions of the base class. That base function is said to be overridd

×