what are the oops concept in java explain with real time
examples

Answer Posted / bhaskara reddy akepati

Abstraction:
Hiding unnecessary things and showing the essential
information.

Example: Suppose take a car: In that we will have breaks
and stering and etc... Here when we are changing the gear
box to up or bottom then gears will work but we don't know
how they are managing internally and we don't no how it is
working. As a driver we don't need to know how it is
working internally when we are changing every time. That is
the reason they will hide the wires and cables internally
and they will show up only gear box to us.

Advantages: 1) Code will be clean and for managing it will
be very easy

Inheritance:

Acquiring the properties from super class to
subclass.

Example: Suppose take two java classes
Class A contains 2 variables and ClassB Extends Class A
that means here ClassB can access the classA variables
without declaring it. If we do this then the memory will be
less and reusable.

Advantages: 1)Reusability of code

Encapsulation: Wrapping up of data and methods into a
single unit.

Example: In our class we need to make all our varables and
methods keeping together.

Advantage: Maintance will be good

Polymorphism: It means many forms.
2 types:
1) Compile time polymorphism
2) Run time polymorphism

Method overloading is an example for Compile time
polymorphism and
Method overriding is an example for Run time polymorphism

Is This Answer Correct ?    24 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there any difference between nested classes and inner classes?

540


What is the use of a copy constructor?

573


What is exception hierarchy in java?

589


How to display names of all components in a Container?

2490


What is the point of java?

554






Why singleton class is used in java?

574


What are the kinds of polymorphism?

611


How to find the largest value from the given array.

526


Explain exception chaining in java?

611


What is nan inf?

507


What is the difference between access specifiers and access modifiers in java? 16

536


What is meant by flickering?

656


If an object reference is set to null, will the garbage collector immediately free the memory held by that object?

637


What is constructor in java ?

636


Explain about the dynamic behavior of core java?

636