Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
Characteristics of OOPS
Name@[email protected]
mwww.facebook.com/ Abhishek H
menon twitter.com/Abhishek H Menonin.linkedin.com/in/Abhishek H
menonPhonenumber:9496519895
Object oriented programming
• is a programming paradigm that represents concepts as “objects” that have data fields and associated procedures known as methods.
• data fields :attributes that describe objects.• methods : some procedures designed for a
specific task.
Object
• which are usually instances of classes, are used to interact with one another to design
applications and computer programs.• An object is an instantiation of class. In terms
of variables, a class would be a type, and an object would be a variable.
Class
• A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions.
e.g. class class_name{access_specifier_1:member_1;access_specifier_2:member_2;………………..
}
Members of Class
• Private: private members are accessible only in the class itself.
• Public: public members are accessible outside the class(anywhere).
• Protected :protected members are accessible in the same package, and in the subclasses of the class and inside the class.
Characteristics of OOPS
• Data Encapsulation• Inheritance• Polymorphism• Data Abstraction
Encapsulation
• It is the mechanism that binds the data & function in one form known as class. The data and function may be private or public.
• Encapsulation guarantees the integrity of the data contained in the object.
Object binds together in the form of a class..
Animal
Dog Fish
MuttBull StarGold
Cat
Inheritance
• Mechanism of deriving a new class from an already existing class.
• 5 levels of inheritance-Single level-Multilevel-Multiple
-Hierarchical-Hybrid
Types of Inheritance
Base Class
Derived Class
Single level
Multi Level
Flower
Rose India
World
Rajastan
Jaipur
Types of Inheritance
Bird
PigeonParrot
Multiple
Base Class
Derived
Types of Inheritance
• Single levelClass Base{
Data members and Functions;};Class Derived : Public Base{Data members and Functions;};
• Multiple Class A{};Class B{};Class C:Public A , Public B{};
Types of Inheritance
• Multi LevelClass A{};Class B: Public A{};Class C :Public B{};Class D: Public C{};
Hierarchical Inheritance
B DC
A
G HFE
Hybrid Inheritance
• Combination of the above types of inheritances.
e.g. Hierarchical + MultipleMulti level + Multiple etc.
Polymorphism
• Poly means many. Morphism means forms.• Polymorphism feature enables classes to
provide different implementation of methods having the same name.
• Two types of Polymorphism – Compile time (Overloading)– Run time(Overriding)
Overloading
• Overloading– In method overloading, a method is executed
depending on the number and type of parameters passed to it.
– When we compile the class, the compiler binds the appropriate method to the object based on the method’s arguments. This is called early binding and this process is referred to as compile time polymorphism
Overriding
• You can have a method in subclass overrides the method in its super classes with the same name and signature. Java virtual machine determines the proper method to call at the runtime, not at the compile time.
Abstraction
• Abstraction is simplifying complex reality by modelling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.
• It deals with the outside view of the object.
Abstraction
• Modifiers:If you want to access a particular variable , method or class from anywhere , then make that variable accessible by using public modifier.
If you want to restrict a particular variable , method or class to be accessible outside the class , use private modifier.
Abstraction v/s Encapsulation• class person
{private String name;public void main(){System.out.println(""+name);
}}
• Abstraction means giving useful information , Encapsulation means hiding unnecessary information.
If this presentation helped you, please visit our page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us