6/22/2017 - 7:06 AM

slimwiki link :

What Is an Object?

Real-world objects share two characteristics: They all have state and behavior.
Dogs have state (name, color, breed, hungry) and behavior (barking, fetching,
wagging tail).

So ware objects are conceptually similar to real-world objects: they too consist
of state and related behavior. An object stores its state in elds (variables in
some programming languages) and exposes its behavior through methods
(functions in some programming languages). Methods operate on an object's
internal state and serve as the primary mechanism for object-to-object
communication. Hiding internal state and requiring all interaction to be
performed through an object's methods is known as data encapsulation — a
fundamental principle of object-oriented programming.


When one task is performed by different ways i.e. known as polymorphism.
For example: to convince the customer differently, to draw something e.g.
shape or rectangle etc.

In java, we use method overloading and method overriding to achieve

Another example can be to speak something e.g. cat speaks meaw, dog barks
woof etc.


Hiding internal details and showing functionality is known as abstraction.
For example: phone call, we don't know the internal processing.

In java, we use abstract class and interface to achieve abstraction.


Binding (or wrapping) code and data together into a single unit is known as
encapsulation. For example: capsule, it is wrapped with different medicines.

What is exception handling

The core advantage of exception handling is to maintain the normal  ow of
the application. Exception normally disrupts the normal  ow of the
application that is why we use exception handling. Let's take a scenario:

Suppose there is 10 statements in your program and there occurs an exception
at statement 5, rest of the code will not be executed i.e. statement 6 to 10 will
not run. If we perform exception handling, rest of the statement will be
executed. That is why we use exception handling in java.