This presentation will helpful for Android Beginner's to refresh the OOPS Concepts which is very basic things for Android Mobile Application Development.
Boost Fertility New Invention Ups Success Rates.pdf
Basics of oops concept
1.
2. Object Oriented Programming System
Object Oriented Programming is a methodology to design a
program using Classes and Objects.
It simplifies the software development and maintenance by
providing some concepts:
Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
3. OBJECT
A runtime entity that has state and behavior is known as Object.
Object= data + method ,Object is an instance of a class.
An object has these characteristics:
State: represents the data of an Object.
Behavior: represents the behavior of an Object.
Identity: object is typically implemented via a unique ID.
Real time Example:
4. CLASS
A Class is a group of objects that have common property.
(or)
Collection of Objects.
It is a Template or Blue Print from which objects are created.
Syntax to declare a Class:
Class <class name>
{
data member;
method;
}
5. Example for Class and Object:
Class student
{
String name = “DineshKumar”;
int phoneno = “9500012345”;
public static void main( string[] args)
{
Student s1 = new student(); // object
System.out.println(“Name is:” +s1.name);
System.out.println(“Phone No:” +s1.phoneno);
}
}
Output:
Name is: DineshKumar
Phone No: 9500012345
6. ABSTRACTION
Abstraction is a process of hiding the implementation details
and showing only functionality to the user.
(OR)
It highlights the essential things to the user and hides
the non- essential things.
Real Time Example:
Sending SMS: you just type the text and send the message
you don’t know the internal processing about message delivery.
Syntax to declare the abstract class:
Abstract class < class- name>
{
}
7. INTERFACE
An Interface is a blue print of a class; it has static constants and
abstract methods.
Interface is used to achieve fully abstraction
and Multiple Inheritances in Java.
An implement is a keyword to implement
the interface in a class.
Java does not support multiple inheritance.
Multiple Inheritance is not supported in case of class but it is
supported in case of interface because there is no ambiguity as
implementation is provided by the implementation class.
8. ENCAPSULATION
Encapsulation is a process of wrapping code and Data together
into a single unit.
We can calculate a fully encapsulated class 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.
In a encapsulated class we can access only the methods
we can’t able to access the data that scenario is called Data Hiding.
Data’s
Method’s
9. INHERITANCE
Inheritance is a mechanism in which one object acquires and the
properties and behaviors of parent class. A new class derived from
old class.
Syntax for Inheritance:
class subclass name extends super class name
{
}
extends is a key word is used to inherit one class for another class.
To reduce the complexity and simplify the language, multiple
interfaces are not supported in Java.
10. POLYMORPHISM
In general polymorphism is a particular thing behave
differently in a different situation
Two types of Polymorphism:
Compile time Polymorphism
Run time Polymorphism
Run time Polymorphism Example: Method Overloading.
Compile time Polymorphism Example: Method Overriding.
Real time Example:
Mobile Phone: It acts like a phone where you calling to
someone.
It acts like a camera whiles you taking a snap.
It acts like a Music player whiles you hearing song from that.
11. Run time Polymorphism
Method overloading:
Method having same name but difference
in the number of arguments and its data type.
Example:
Sum( int a, int b)
Sum( int a, int b, int c)
Sum( float a, float b)
Sum( float a, float b, float c)
For example the entire method names are same but the main
difference in the number of arguments and its data type.
12. Compile Time Polymorphism
Method Overriding:
Method having same name, same number of arguments and its
data type.
overriding method MUST have the same argument list (if not, it
might be a case of overloading)
overriding method MUST have the same return type; the
exception is covariant return (used as of Java 5) which returns a
type that is a subclass of what is returned by the over riden
method