Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views

Java OOP Concepts 1

Uploaded by

mic.pess
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Java OOP Concepts 1

Uploaded by

mic.pess
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Java OOPs Concepts_1

OOps (Object-Oriented Programming System) - object means a real-world entity such as pen, chair, table.
OOP is a methodology of paradigm to design a program using classes and objects. It simplifies soft develop.
by providing some concepts:

Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation

Apart from these concepts, there are some other termins which are used in OOP design:

Coupling
Cohesion
Assocation
Aggregation
Composition

OBJECT:

entity that has state and behaviour


For example: chair, table, pen, bike (can be physical or logical)
can be defined as an instance of a class
objects can communicate without knowing details of each other's data or code
Example: dog is an object - it has states: color, name, breed, etc. also behaviours like: barking, eaton,
drinking, wagging the tail.

CLASS:

collection of objects / it is a logical entity

INHERITANCE:
when one object acquires all the properties and behaviours of a parent object, it is known as
inheritance, it provides code reusability. It is used to achieve runtime polymorphism.

POLYMORPHISM:

if one task is performed in different ways, it is known as polymorphism.


For example: to convince the customer differently, to draw something, shape,triangle, rectangle, etc.
we use method overloading and overriding to achieve polymorphism.
example of speaking: cat - speak - meow, dog - speak woof, etc.

ABSTRACTION:

hiding internal details and showing functionality is know as abstraction


for example: phone call - we do not know the internal processing
in JAVA we use abstract class and interface to achiev abstraction

ENCAPSULATION:

Binding (or wrapping) code and data together into a single unit are known as encapsulation.
For example: a capsule - it is wrapped with different medicines
JAVA CLASS is the example of encapsulation. JAVA BEAN is the fully encapsulated class because all
the data members are private.

COUPLING:

refers to the knowledge or information or dependency of another class


if a class has the details information of another class - there is strong coupling
in JAVA we use private, protected and public modifiers to display visibility level of class, method and
field.

COHESION:

referes to the level of a component which performs a single well-defined task.


signel well-defined task si done by a highly cohesive method
java.io package is a highly cohesive package because it has I/O related classes and interface
java.util package is a weakly cohesive package becuase it has unrelated classes and interfaces.

ASSOCIATION:

relationship between the objects (one object can be associated with one or many objects)
There can be four types of association between the objects (one to one, one to many, many to one,
many to many)
Example: one country can have one prime minister(one to one), prime minister can have many
ministers (one to many), Also many MP's can have one prime minister(many to one), many ministers
can have many departments(many to many).
can be undirectional or bidirectional

AGGREGATION:

way to achieve Association


represent the relationship where one object contains other objects as a part of its state
represents the weak relationship between objects
has-a relationship in JAVA / example: inheritance is-a relationship

COMPOSITION:

also a way to achieve Association


strong relationship between the containing object and the dependent object
if you delete the parent object, all the child objects will be deleted automatically

You might also like