what are the oops concept in java explain with real time
examples
Answer Posted / ramya
1)Abstraction:
Abstraction is a way to remove the association of the
behavior of an object with the actual details behind the
scenes which implement that object's behavior. This
'abstraction' is usually accomplished through the use of
base classes with virtual functions; each derived function
provides the details that implement the behavior behind that
abstraction.
eg/we invented flight based on the mechanism of Birds. So
flight is derived form the base of birds.
2)Encapsulation:
It is a process of binding or wrapping the data and the
codes that operates on the data into a single entity. This
keeps the data safe from outside interface and misuse. One
way to think about encapsulation is as a protective wrapper
that prevents code and data from being arbitrarily accessed
by other code defined outside the wrapper.
eg/ Ink is the important component in pen but it is hiding
by some other material
3)Polymorphism:
a single function or single operator has different character
in different place.
eg/A girl plays a role of daughter at home and a manager at
office
4)Inheritance:
The new classes, known as derived classes, take over (or
inherit) attribute and behavior of the pre-existing classes,
which are referred to as base classes (or Parent classes).
It is intended to help reuse existing code with little or no
modification.
eg/ parent-child relation
| Is This Answer Correct ? | 190 Yes | 63 No |
Post New Answer View All Answers
Why does java does not support multiple inheritance? Explain
What happens when you add a double value to a string?
Explain the protected field modifier?
What is array class in java?
Explain what are final variable in java?
What must a class do to implement an interface in java programming?
Can we define constructor in inner class?
What is the default access specifier for variables and methods of a class?
Can we create our own daemon thread?
Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?
What is difference between float and double?
What is compareto () in java?
Is math class static in java?
Why are getters and setters used?
Can singleton class be cloned?