Labels
- Apache (10)
- Articles (4)
- BPM Tools (5)
- Glassfish (16)
- Hadoop (10)
- HP ALM (6)
- HP SOA Systinet (14)
- Issues (19)
- JAVA (85)
- JBoss (16)
- jQuery (4)
- Load Runner (37)
- Quality Center (49)
- Testing (24)
- Tips and Tricks (16)
- Tomcat (4)
- Usefull Links (18)
- Weblogic (41)
- WebSphere (2)
Tuesday, April 16, 2013
Easy Understanding of OOPs concepts
There are many terms in Object Oriented programing , together these terms are called as OOP s concepts . These OOP s concepts are used in all modern programming languages like Java , J2EE,C++ , C#, .Net , Python and Javascript .Lets us begin with these OOPs concepts.
Class
Class is the 1st OOPs concept .Class defines the characteristics of objects which includes its attributes , fields properties and behavior . Let us say we have a class called car , then the color , model number , top speed can be its attributes and properties . Accelerating , breaking , turning will be its behavior .
Objects
Objects can be considered as a thing that performs a set of related functions .Programming objects are used to model real worlds objects. An object is also an instant of a class . For our class Car , Ferrari will be our object
Instance
One can have an instance of a class; the instance is the actual object created at runtime. The set of values of the attributes of a particular object is called its state. The object consists of state and the behaviour that’s defined in the object’s class.
Method
Also called as functions in some programming languages , methods defines the behavior of particular objects . For our Car class , turning() , breaking () will be our methods .
Inheritance
In the real world there are many objects that can be specialized. In OOP, a parent class can inherit its behavior and state to children classes. This concept was developed to manage generalization and specialization in OOP .Lets say we have a class called Car and Racing Car . Then the attributes like engine no. , color of the Class car can be inherited by the class Racing Car . The class Car will be Parent class , and the class Racing Car will be the derived class or child class
The following OO terms are commonly used names given to parent and child classes in OOP:
Superclass: Parent class.
Subclass: Child class.
Base class: Parent class.
Derived class: Child class
Abstraction
Abstraction is simplifying complex reality by modeling classes appropriate to the problem . In other words it means representing only the important details without including all the details . For example the car Ferrari can be treated as simple car only .
Encapsulation
The wrapping up of data and functions into a single unit is called as encapsulation . For example the class car has a method turn () .The code for the turn() defines how the turn will occur . So we don’t need to define how Mercedes will turn and how the Ferrari will turn separately . turn() can be encapsulated with both.
Polymorphism
Its an important OOPs concept , Polymorphism means taking more than one forms .Polymorphism allows the programmer to treat derived class members just like their parent class’s members. More precisely, Polymorphism in object-oriented programming is the ability of objects belonging to different data types to respond to calls of methods of the same name .If a Dog is commanded to speak(), this may elicit a bark(). However, if a Pig is commanded to speak(), this may elicit an oink(). Each subclass overrides the speak() method inherited from the parent class Animal.
JAVA OOPS explain with real time examples
OOPS Concepts are mainly 4
1.Abstraction
2.Encapsulation
3.Inheritance
4.Polymorphisam
Abstraction:-Hidding non-essential features and showing the
essential features
(or)
Hidding unnecessary data from the users details,is called
abstraction.
Real Time example:TV Remote Button
in that number format and power buttons and other buttons
there.just we are seeing the butttons,we don't see the
button circuits.i.e buttons circutes and wirings all are
hidden.so i think its good example.
Encapsulation:
Writing Operations and methods stored in a single
class.This is Called Encapsulation
Real Time Example:Medical Capsuals
i.e one drug is stored in buttom layer and another drug is
stored in Upper layer these two layers are combined in
single capsual.
Inheritance:
The New Class is Existing from Old Class,i.e SubClass is
Existing from Super Class.
Real Time Example:
Father and Son Relationship
Polymorphisam:
Sinle Form behaving diffreantly in diffreant
Situations.
Example:-
Person
Person in Home act is husband/son,
in Office acts Employer.
in Public Good Cityzen.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment