SlideShare a Scribd company logo
1 of 24
An introduction to Java
Object
 Object is a computer representation of some real-world
thing (i.e person, place) or event.
 Objects can have both attributes and behaviors.
 An object can be considered a "thing" that can perform a
set of related activities.
 The set of activities that the object performs defines the
object's behavior.
 The process of creating objects from a class is called
instantiation.
 An object is an instance of a class.
 A reference value denotes a particular object.
Class
 A class is simply a representation of a type of object.
 It is the blueprint/ plan/ template that describe the
details of an object.
 A class is the blueprint from which the individual
objects are created.
 Class is composed of three things: a name, attributes,
and operations.
Encapsulation
 Encapsulation (or information hiding) is a principle, about hiding
the details of the implementation of the interface.
 It is to reveal as little as possible about the inner workings of the
Interface.
 The encapsulation is the inclusion within a program object of all the
resources needed for the object to function - basically, the methods
and the data.
 The class is kind of a container or capsule or a cell, which encapsulate
the set of methods, attribute and properties to provide its indented
functionalities to other classes.
 In that sense, encapsulation also allows a class to change its internal
implementation without hurting the overall functioning of the system.
 An object has properties and behaviors that are encapsulated inside the
object.
 The object offers services to the client but implementation of its
properties and behavior is not a concern of the client and can be
altered without client’s knowledge.
Association
 Association is a (*a*) relationship between two classes,
where one class use another.
 It allows one object instance to cause another to
perform an action on its behalf.
 The relationship is structural, because it specifies that
objects of one kind are connected to objects of
another.
 Association is the more general term that define the
relationship between two classes, where as the
aggregation and composition are relatively special.
Aggregation
 Aggregation is a special type of an association.
 Aggregation is the (*the*) relationship between two
classes.
 When object of one class has an (*has*) object of another,
if second is a part of first (containment relationship) then
we called that there is an aggregation between two classes.
 Aggregation is used to represent ownership or a whole/part
relationship.
 It is either the process of creating a new object from two or
more other objects, or an object that is composed of two or
more other objects.
Composition
 Composition is recognized as a special type of an
Aggregation.
 In the composite relationship in-between say object1 and
object2, they mutually depend on each other.
 Composition is used to represent an even stronger form of
ownership than Aggregation.
 Example:
 Say University aggregate Chancellor or University has an
(*has-a*) Chancellor. But even without a Chancellor a
University can exists. But the Faculties cannot exist without
the University, the life time of a Faculty (or Faculties)
attached with the life time of the University.
Abstraction
 Abstraction is an emphasis on the idea, qualities and
properties rather than the particulars (a suppression of
detail).
 The importance of abstraction is derived from its
ability to hide irrelevant details and from the use of
names to reference objects.
 It places the emphasis on what an object is or does
rather than how it is represented or how it works.
 Thus, it is the primary means of managing complexity
in large programs.
Generalization
 Generalization reduces the complexity by replacing
multiple entities which perform similar functions with a
single construct.
 Generalization is the broadening of application to
encompass a larger domain of objects of the same or
different type.
 Programming languages provide generalization through
variables, parameterization, generics and polymorphism.
 It places the emphasis on the similarities between objects.
 Thus, it helps to manage complexity by collecting
individuals into groups and providing a representative
which can be used to specify any individual of the group.
Specialization
 It is the process of defining a new object based on a
(typically) more narrow definition of an existing
object, or an object that is directly related to, and more
narrowly defined than, another object.
 To create a subclass is specialization, to factor out
common parts of derived classes into a common base
(or parent) is generalization.
Abstract Class
 Abstract class cannot be instantiated.
 It can only be used as a super-class for other classes that extend
the abstract class.
 Abstract class is the concept and implementation gets completed
when it is being realized by a subclass.
 In addition to this a class can inherit only from one abstract class
(but a class may implement many interfaces) and must override
all its abstract methods/ properties and may override virtual
methods/ properties.
 Abstract classes can carry a functional “payload” that numerous
subclasses can inherit and use directly, compared to interfaces.
 Abstract classes can have all or no abstract methods.
 The abstract keyword cannot be applied to static methods.
 Abstract method cannot be declared private.
 Abstract class may have constructors, but they cannot be used to
instantiate the abstract class.
Interface
 Interface separates the implementation and defines the
structure.
 It is useful in cases where you need to change the
implementation frequently.
 They are used to define a generic template and then one or more
abstract classes to define partial implementations of the
interface.
 An interface like that of an abstract class cannot be instantiated.
 A class that implements an interface does not define all the
methods of the interface, then it must be declared abstract and
the method definitions must be provided by the subclass that
extends the abstract class.
 An interfaces can inherit other interfaces.
Interface versus Abstract
 Interface has no implementation, but they have to be implemented.
 Abstract class’s methods can have implementations and they have to be
extended.
 Interfaces can only have method declaration (implicitly public and abstract)
and fields (implicitly public static)
 Abstract class’s methods can’t have implementation only when declared
abstract.
 Interface can inherit more than one interfaces
 Abstract class can implement more than one interfaces, but can inherit only one
class
 Abstract class must override all abstract method and may override virtual
methods
 Interface can be used when the implementation is changing
 Abstract class can be used to provide some default behavior for a base class.
 Interface makes implementation interchangeable
 Interface increase security by hiding the implementation
 Abstract class can be used when implementing framework
 Abstract classes are an excellent way to create planned inheritance hierarchies
and also to use as non-leaf classes in class hierarchies.
Polymorphism
 Polymorphism is the ability to create a variable, a function,
or an object that has more than one form.
 It is the ability to request that the same operations be
performed by a wide range of different types of things.
 It enables the objects belonging to different types to
respond to a method, field, or property calls of the same
name, each one according to an appropriate type-specific
behavior (dynamic binding).
 It enables the objects of various types to define a common
interface of operations for users.
 It allows a reference to denote objects of different types at
different times during execution.
Cohesion and Coupling
 Cohesion is an inter-class measure of how well-structured and
closely-related the functionality is in a class.
 The objective is to design classes with high cohesion, performing
well-defined and related tasks.
 Lack of cohesion in a class means that the purpose of the class is
not focused, and unrelated functionality is ending up in the
class.
 Coupling is a measure of intra-class dependencies.
 Objects need to interact with each other to carry out the task.
 The dependencies should however be minimized to achieve
loose coupling, and to aid in creating extensible applications.
 The exposure of implementation details of an object is a major
source of Intra-class dependencies and can impede changes in
the implementation of the object.
 High cohesion and loose coupling help to achieve the main goals
of OO design: maintainability, reusability, extensibility, and
reliability.
Method Overloading and Overriding
 Polymorphism is only concerned with the application
of specific implementations to an interface or a more
generic base class.
 Method overloading refers to methods that have same
name but different signatures inside the same class.
 Method overriding is where a subclass replaces the
implementation of one or more of its parent's
methods.
 Neither method overloading nor method overriding
are by themselves implementations of polymorphism
Inheritance
 It is a technique to compartmentalize and reuse code
by creating collections of attributes and behaviors
called Objects based on previously created objects.
 Inheritance aids in the reuse of code.
 The new classes, known as subclasses (or derived
classes), inherit attributes and behavior of the pre-
existing classes, which are referred to as super classes.
 The inheritance relationships of classes gives rise to a
class hierarchy.
Access Modifiers
 They determine whether other classes can use a particular field or
invoke a particular method.
 There are two levels of access control:
 1) At the top level—public, or package-private (no explicit modifier).
 2) At the member level—public, private, protected, or package-
private (no explicit modifier).
 Public: When the modifier is public member is visible to all classes.
 Private: The private modifier specifies that the member can only be
accessed within its own class.
 Protected: The protected modifier specifies that the member can only
be accessed within its own package and its subclass even in another
package.
 Default: If a class has no modifier (the default, also known as package-
private), member is visible only within its own package.
Access Modifiers
 A class can only have public or default modifier.
 In every java source code file, only one class in the file
is public accessible, and that class must have the same
name as the file.
 Use private unless you have a good reason not to.
 Avoid public fields except for constants.
Specifier Public Private Protected Default
Class Y Y Y Y
Sub Class Y N Y N
Package Y N N Y
All Classes Y N N N
Constructors
 Constructors are used to initialize the instance variables (fields)
of an object.
 Constructors must have the same name as the class.
 Constructors do not have a return value declaration.
 If you don't define a constructor for a class, a default parameter-
less constructor is automatically created by the compiler, calling
the default parent constructor (super()) and initializes all
instance variables to default values.
 If you define any constructor for your class, no default
constructor is automatically created.
 The first line of a constructor must either be a call on another
constructor in the same class, or a call on the superclass
constructor.
 If the first line is neither of these, the compiler automatically
inserts a call to the parameter-less super class constructor.
 Constructors can have the same access specifiers used for
variables and methods.
this and super Keywords
 this calls another constructor in same class.
 super calls a constructor in a parent class.
 The Java compiler inserts a call to the parent
constructor (super) if you don't have a constructor call
as the first statement of you constructor.
Static keyword
 Fields that have the static modifier in their declaration are
called static fields or class variables.
 They are associated with the class, rather than with any
object, hence can be manipulated without creating an
instance of the class.
 Methods having static modifier are invoked with the class
name, without the need for creating an instance of class.
 A common use for static methods is to access static fields.
 Static methods cannot access instance variables or
instance methods directly without an object reference.
 Static methods cannot use the this keyword as there is no
instance for this to refer to.
Final keyword
 The final modifier can be applied to four Java constructs:
 variables: a final variable can be set once and only once,
allowing to declare local constants. They must be assigned
exactly once.
 fields: a final field can also be set only once, by the
constructor of the class which defines it.
 methods: a final method cannot be overridden nor
hidden.
 classes: a final class cannot be extended. A final class has
all its method declared final. On the other hand, fields of a
final class do not have any special property.
Final keyword continued
 Final parameters are not considered part of the
method signature, and are ignored by the compiler
when resolving method calls.
 Anonymous local classes can only reference local
variables and parameters that are declared final.
 Private and static methods are always implicitely final,
since they cannot be overridden.

More Related Content

What's hot

Lecture 13
Lecture 13Lecture 13
Lecture 13Rana Ali
 
Relations Class Diagram
Relations Class DiagramRelations Class Diagram
Relations Class Diagramhalwal
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UMLyndaravind
 
Object Interconnections
Object InterconnectionsObject Interconnections
Object Interconnectionsadil raja
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Techglyphs
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented conceptschristradus
 
Ch 5 O O Data Modeling
Ch 5  O O  Data ModelingCh 5  O O  Data Modeling
Ch 5 O O Data Modelingguest8fdbdd
 
Barzilay & Lapata 2008 presentation
Barzilay & Lapata 2008 presentationBarzilay & Lapata 2008 presentation
Barzilay & Lapata 2008 presentationRichard Littauer
 
Micro Anti-patterns in Java Code
Micro Anti-patterns in Java CodeMicro Anti-patterns in Java Code
Micro Anti-patterns in Java CodeGanesh Samarthyam
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Object oriented architecture in erp
Object  oriented architecture in erpObject  oriented architecture in erp
Object oriented architecture in erpPreyanshu Saini
 

What's hot (20)

Object modeling
Object modelingObject modeling
Object modeling
 
Lecture 13
Lecture 13Lecture 13
Lecture 13
 
Object modeling
Object modelingObject modeling
Object modeling
 
Ooad
OoadOoad
Ooad
 
Mediator
MediatorMediator
Mediator
 
Relations Class Diagram
Relations Class DiagramRelations Class Diagram
Relations Class Diagram
 
Ashish oot
Ashish ootAshish oot
Ashish oot
 
Mediator pattern
Mediator patternMediator pattern
Mediator pattern
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 
Object Interconnections
Object InterconnectionsObject Interconnections
Object Interconnections
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
Ch 5 O O Data Modeling
Ch 5  O O  Data ModelingCh 5  O O  Data Modeling
Ch 5 O O Data Modeling
 
Barzilay & Lapata 2008 presentation
Barzilay & Lapata 2008 presentationBarzilay & Lapata 2008 presentation
Barzilay & Lapata 2008 presentation
 
Micro Anti-patterns in Java Code
Micro Anti-patterns in Java CodeMicro Anti-patterns in Java Code
Micro Anti-patterns in Java Code
 
Chapter3
Chapter3Chapter3
Chapter3
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Object oriented architecture in erp
Object  oriented architecture in erpObject  oriented architecture in erp
Object oriented architecture in erp
 
O ops concepts
O ops conceptsO ops concepts
O ops concepts
 
Interfaces & Packages V2
Interfaces & Packages V2Interfaces & Packages V2
Interfaces & Packages V2
 

Viewers also liked

ICSME14 - On the Impact of Refactoring Operations on Code Quality Metrics
ICSME14 - On the Impact of Refactoring Operations on Code Quality MetricsICSME14 - On the Impact of Refactoring Operations on Code Quality Metrics
ICSME14 - On the Impact of Refactoring Operations on Code Quality MetricsOscar Chaparro
 
A Validation of Object-Oriented Design Metrics as Quality Indicators
A Validation of Object-Oriented Design Metrics as Quality IndicatorsA Validation of Object-Oriented Design Metrics as Quality Indicators
A Validation of Object-Oriented Design Metrics as Quality Indicatorsvie_dels
 
Pressman ch-11-component-level-design
Pressman ch-11-component-level-designPressman ch-11-component-level-design
Pressman ch-11-component-level-designOliver Cheng
 
Metricas de software
Metricas de softwareMetricas de software
Metricas de softwaresophialara123
 
Chapter 6 software metrics
Chapter 6 software metricsChapter 6 software metrics
Chapter 6 software metricsdespicable me
 

Viewers also liked (8)

ICSME14 - On the Impact of Refactoring Operations on Code Quality Metrics
ICSME14 - On the Impact of Refactoring Operations on Code Quality MetricsICSME14 - On the Impact of Refactoring Operations on Code Quality Metrics
ICSME14 - On the Impact of Refactoring Operations on Code Quality Metrics
 
Oop 2
Oop 2Oop 2
Oop 2
 
A Validation of Object-Oriented Design Metrics as Quality Indicators
A Validation of Object-Oriented Design Metrics as Quality IndicatorsA Validation of Object-Oriented Design Metrics as Quality Indicators
A Validation of Object-Oriented Design Metrics as Quality Indicators
 
Sonar Metrics
Sonar MetricsSonar Metrics
Sonar Metrics
 
Pressman ch-11-component-level-design
Pressman ch-11-component-level-designPressman ch-11-component-level-design
Pressman ch-11-component-level-design
 
Metricas de software
Metricas de softwareMetricas de software
Metricas de software
 
Chapter 6 software metrics
Chapter 6 software metricsChapter 6 software metrics
Chapter 6 software metrics
 
Arquitectura
ArquitecturaArquitectura
Arquitectura
 

Similar to Object Oriented Principles

Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming conceptPina Parmar
 
OOps Interview questions.pdf
OOps Interview questions.pdfOOps Interview questions.pdf
OOps Interview questions.pdfGeekster
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and oodthan sare
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingmustafa sarac
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming languageMd.Al-imran Roton
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingAmit Soni (CTFL)
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfArpitaJana28
 
All 23 Design patterns in one page front and back
All 23 Design patterns in one page front and backAll 23 Design patterns in one page front and back
All 23 Design patterns in one page front and backTrey Brister
 
Basic design pattern interview questions
Basic design pattern interview questionsBasic design pattern interview questions
Basic design pattern interview questionsjinaldesailive
 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfJP Chicano
 
Fundamentals of oops in .Net
Fundamentals of oops in .NetFundamentals of oops in .Net
Fundamentals of oops in .NetHarman Bajwa
 
SE18_Lec 06_Object Oriented Analysis and Design
SE18_Lec 06_Object Oriented Analysis and DesignSE18_Lec 06_Object Oriented Analysis and Design
SE18_Lec 06_Object Oriented Analysis and DesignAmr E. Mohamed
 

Similar to Object Oriented Principles (20)

Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
 
OOps Interview questions.pdf
OOps Interview questions.pdfOOps Interview questions.pdf
OOps Interview questions.pdf
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and ood
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Sda 7
Sda   7Sda   7
Sda 7
 
Oops
OopsOops
Oops
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
All 23 Design patterns in one page front and back
All 23 Design patterns in one page front and backAll 23 Design patterns in one page front and back
All 23 Design patterns in one page front and back
 
Basic design pattern interview questions
Basic design pattern interview questionsBasic design pattern interview questions
Basic design pattern interview questions
 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdf
 
Oops in vb
Oops in vbOops in vb
Oops in vb
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
Fundamentals of oops in .Net
Fundamentals of oops in .NetFundamentals of oops in .Net
Fundamentals of oops in .Net
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Ooad 2
Ooad 2Ooad 2
Ooad 2
 
OOP design patterns
OOP design patternsOOP design patterns
OOP design patterns
 
Oops slide
Oops slide Oops slide
Oops slide
 
SE18_Lec 06_Object Oriented Analysis and Design
SE18_Lec 06_Object Oriented Analysis and DesignSE18_Lec 06_Object Oriented Analysis and Design
SE18_Lec 06_Object Oriented Analysis and Design
 

More from Emprovise

Highlights of AWS ReInvent 2023 (Announcements and Best Practices)
Highlights of AWS ReInvent 2023 (Announcements and Best Practices)Highlights of AWS ReInvent 2023 (Announcements and Best Practices)
Highlights of AWS ReInvent 2023 (Announcements and Best Practices)Emprovise
 
Leadership and Success Lessons for Life/Business
Leadership and Success Lessons for Life/BusinessLeadership and Success Lessons for Life/Business
Leadership and Success Lessons for Life/BusinessEmprovise
 
Secure socket layer
Secure socket layerSecure socket layer
Secure socket layerEmprovise
 
Effective java
Effective javaEffective java
Effective javaEmprovise
 
EJB3 Advance Features
EJB3 Advance FeaturesEJB3 Advance Features
EJB3 Advance FeaturesEmprovise
 
Enterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEnterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEmprovise
 
RESTful WebServices
RESTful WebServicesRESTful WebServices
RESTful WebServicesEmprovise
 
J2EE Patterns
J2EE PatternsJ2EE Patterns
J2EE PatternsEmprovise
 
Spring Web Services
Spring Web ServicesSpring Web Services
Spring Web ServicesEmprovise
 
Spring Web Webflow
Spring Web WebflowSpring Web Webflow
Spring Web WebflowEmprovise
 
Spring Web Views
Spring Web ViewsSpring Web Views
Spring Web ViewsEmprovise
 
Enterprise Spring
Enterprise SpringEnterprise Spring
Enterprise SpringEmprovise
 
Spring Basics
Spring BasicsSpring Basics
Spring BasicsEmprovise
 
Apache Struts 2 Advance
Apache Struts 2 AdvanceApache Struts 2 Advance
Apache Struts 2 AdvanceEmprovise
 
Apache Struts 2 Framework
Apache Struts 2 FrameworkApache Struts 2 Framework
Apache Struts 2 FrameworkEmprovise
 
Java Servlets
Java ServletsJava Servlets
Java ServletsEmprovise
 

More from Emprovise (20)

Highlights of AWS ReInvent 2023 (Announcements and Best Practices)
Highlights of AWS ReInvent 2023 (Announcements and Best Practices)Highlights of AWS ReInvent 2023 (Announcements and Best Practices)
Highlights of AWS ReInvent 2023 (Announcements and Best Practices)
 
Leadership and Success Lessons for Life/Business
Leadership and Success Lessons for Life/BusinessLeadership and Success Lessons for Life/Business
Leadership and Success Lessons for Life/Business
 
Secure socket layer
Secure socket layerSecure socket layer
Secure socket layer
 
Effective java
Effective javaEffective java
Effective java
 
EJB3 Advance Features
EJB3 Advance FeaturesEJB3 Advance Features
EJB3 Advance Features
 
Enterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEnterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business Logic
 
EJB3 Basics
EJB3 BasicsEJB3 Basics
EJB3 Basics
 
RESTful WebServices
RESTful WebServicesRESTful WebServices
RESTful WebServices
 
J2EE Patterns
J2EE PatternsJ2EE Patterns
J2EE Patterns
 
Spring JMS
Spring JMSSpring JMS
Spring JMS
 
JMS
JMSJMS
JMS
 
Spring Web Services
Spring Web ServicesSpring Web Services
Spring Web Services
 
Spring Web Webflow
Spring Web WebflowSpring Web Webflow
Spring Web Webflow
 
Spring Web Views
Spring Web ViewsSpring Web Views
Spring Web Views
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Enterprise Spring
Enterprise SpringEnterprise Spring
Enterprise Spring
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 
Apache Struts 2 Advance
Apache Struts 2 AdvanceApache Struts 2 Advance
Apache Struts 2 Advance
 
Apache Struts 2 Framework
Apache Struts 2 FrameworkApache Struts 2 Framework
Apache Struts 2 Framework
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Object Oriented Principles

  • 2. Object  Object is a computer representation of some real-world thing (i.e person, place) or event.  Objects can have both attributes and behaviors.  An object can be considered a "thing" that can perform a set of related activities.  The set of activities that the object performs defines the object's behavior.  The process of creating objects from a class is called instantiation.  An object is an instance of a class.  A reference value denotes a particular object.
  • 3. Class  A class is simply a representation of a type of object.  It is the blueprint/ plan/ template that describe the details of an object.  A class is the blueprint from which the individual objects are created.  Class is composed of three things: a name, attributes, and operations.
  • 4. Encapsulation  Encapsulation (or information hiding) is a principle, about hiding the details of the implementation of the interface.  It is to reveal as little as possible about the inner workings of the Interface.  The encapsulation is the inclusion within a program object of all the resources needed for the object to function - basically, the methods and the data.  The class is kind of a container or capsule or a cell, which encapsulate the set of methods, attribute and properties to provide its indented functionalities to other classes.  In that sense, encapsulation also allows a class to change its internal implementation without hurting the overall functioning of the system.  An object has properties and behaviors that are encapsulated inside the object.  The object offers services to the client but implementation of its properties and behavior is not a concern of the client and can be altered without client’s knowledge.
  • 5. Association  Association is a (*a*) relationship between two classes, where one class use another.  It allows one object instance to cause another to perform an action on its behalf.  The relationship is structural, because it specifies that objects of one kind are connected to objects of another.  Association is the more general term that define the relationship between two classes, where as the aggregation and composition are relatively special.
  • 6. Aggregation  Aggregation is a special type of an association.  Aggregation is the (*the*) relationship between two classes.  When object of one class has an (*has*) object of another, if second is a part of first (containment relationship) then we called that there is an aggregation between two classes.  Aggregation is used to represent ownership or a whole/part relationship.  It is either the process of creating a new object from two or more other objects, or an object that is composed of two or more other objects.
  • 7. Composition  Composition is recognized as a special type of an Aggregation.  In the composite relationship in-between say object1 and object2, they mutually depend on each other.  Composition is used to represent an even stronger form of ownership than Aggregation.  Example:  Say University aggregate Chancellor or University has an (*has-a*) Chancellor. But even without a Chancellor a University can exists. But the Faculties cannot exist without the University, the life time of a Faculty (or Faculties) attached with the life time of the University.
  • 8. Abstraction  Abstraction is an emphasis on the idea, qualities and properties rather than the particulars (a suppression of detail).  The importance of abstraction is derived from its ability to hide irrelevant details and from the use of names to reference objects.  It places the emphasis on what an object is or does rather than how it is represented or how it works.  Thus, it is the primary means of managing complexity in large programs.
  • 9. Generalization  Generalization reduces the complexity by replacing multiple entities which perform similar functions with a single construct.  Generalization is the broadening of application to encompass a larger domain of objects of the same or different type.  Programming languages provide generalization through variables, parameterization, generics and polymorphism.  It places the emphasis on the similarities between objects.  Thus, it helps to manage complexity by collecting individuals into groups and providing a representative which can be used to specify any individual of the group.
  • 10. Specialization  It is the process of defining a new object based on a (typically) more narrow definition of an existing object, or an object that is directly related to, and more narrowly defined than, another object.  To create a subclass is specialization, to factor out common parts of derived classes into a common base (or parent) is generalization.
  • 11. Abstract Class  Abstract class cannot be instantiated.  It can only be used as a super-class for other classes that extend the abstract class.  Abstract class is the concept and implementation gets completed when it is being realized by a subclass.  In addition to this a class can inherit only from one abstract class (but a class may implement many interfaces) and must override all its abstract methods/ properties and may override virtual methods/ properties.  Abstract classes can carry a functional “payload” that numerous subclasses can inherit and use directly, compared to interfaces.  Abstract classes can have all or no abstract methods.  The abstract keyword cannot be applied to static methods.  Abstract method cannot be declared private.  Abstract class may have constructors, but they cannot be used to instantiate the abstract class.
  • 12. Interface  Interface separates the implementation and defines the structure.  It is useful in cases where you need to change the implementation frequently.  They are used to define a generic template and then one or more abstract classes to define partial implementations of the interface.  An interface like that of an abstract class cannot be instantiated.  A class that implements an interface does not define all the methods of the interface, then it must be declared abstract and the method definitions must be provided by the subclass that extends the abstract class.  An interfaces can inherit other interfaces.
  • 13. Interface versus Abstract  Interface has no implementation, but they have to be implemented.  Abstract class’s methods can have implementations and they have to be extended.  Interfaces can only have method declaration (implicitly public and abstract) and fields (implicitly public static)  Abstract class’s methods can’t have implementation only when declared abstract.  Interface can inherit more than one interfaces  Abstract class can implement more than one interfaces, but can inherit only one class  Abstract class must override all abstract method and may override virtual methods  Interface can be used when the implementation is changing  Abstract class can be used to provide some default behavior for a base class.  Interface makes implementation interchangeable  Interface increase security by hiding the implementation  Abstract class can be used when implementing framework  Abstract classes are an excellent way to create planned inheritance hierarchies and also to use as non-leaf classes in class hierarchies.
  • 14. Polymorphism  Polymorphism is the ability to create a variable, a function, or an object that has more than one form.  It is the ability to request that the same operations be performed by a wide range of different types of things.  It enables the objects belonging to different types to respond to a method, field, or property calls of the same name, each one according to an appropriate type-specific behavior (dynamic binding).  It enables the objects of various types to define a common interface of operations for users.  It allows a reference to denote objects of different types at different times during execution.
  • 15. Cohesion and Coupling  Cohesion is an inter-class measure of how well-structured and closely-related the functionality is in a class.  The objective is to design classes with high cohesion, performing well-defined and related tasks.  Lack of cohesion in a class means that the purpose of the class is not focused, and unrelated functionality is ending up in the class.  Coupling is a measure of intra-class dependencies.  Objects need to interact with each other to carry out the task.  The dependencies should however be minimized to achieve loose coupling, and to aid in creating extensible applications.  The exposure of implementation details of an object is a major source of Intra-class dependencies and can impede changes in the implementation of the object.  High cohesion and loose coupling help to achieve the main goals of OO design: maintainability, reusability, extensibility, and reliability.
  • 16. Method Overloading and Overriding  Polymorphism is only concerned with the application of specific implementations to an interface or a more generic base class.  Method overloading refers to methods that have same name but different signatures inside the same class.  Method overriding is where a subclass replaces the implementation of one or more of its parent's methods.  Neither method overloading nor method overriding are by themselves implementations of polymorphism
  • 17. Inheritance  It is a technique to compartmentalize and reuse code by creating collections of attributes and behaviors called Objects based on previously created objects.  Inheritance aids in the reuse of code.  The new classes, known as subclasses (or derived classes), inherit attributes and behavior of the pre- existing classes, which are referred to as super classes.  The inheritance relationships of classes gives rise to a class hierarchy.
  • 18. Access Modifiers  They determine whether other classes can use a particular field or invoke a particular method.  There are two levels of access control:  1) At the top level—public, or package-private (no explicit modifier).  2) At the member level—public, private, protected, or package- private (no explicit modifier).  Public: When the modifier is public member is visible to all classes.  Private: The private modifier specifies that the member can only be accessed within its own class.  Protected: The protected modifier specifies that the member can only be accessed within its own package and its subclass even in another package.  Default: If a class has no modifier (the default, also known as package- private), member is visible only within its own package.
  • 19. Access Modifiers  A class can only have public or default modifier.  In every java source code file, only one class in the file is public accessible, and that class must have the same name as the file.  Use private unless you have a good reason not to.  Avoid public fields except for constants. Specifier Public Private Protected Default Class Y Y Y Y Sub Class Y N Y N Package Y N N Y All Classes Y N N N
  • 20. Constructors  Constructors are used to initialize the instance variables (fields) of an object.  Constructors must have the same name as the class.  Constructors do not have a return value declaration.  If you don't define a constructor for a class, a default parameter- less constructor is automatically created by the compiler, calling the default parent constructor (super()) and initializes all instance variables to default values.  If you define any constructor for your class, no default constructor is automatically created.  The first line of a constructor must either be a call on another constructor in the same class, or a call on the superclass constructor.  If the first line is neither of these, the compiler automatically inserts a call to the parameter-less super class constructor.  Constructors can have the same access specifiers used for variables and methods.
  • 21. this and super Keywords  this calls another constructor in same class.  super calls a constructor in a parent class.  The Java compiler inserts a call to the parent constructor (super) if you don't have a constructor call as the first statement of you constructor.
  • 22. Static keyword  Fields that have the static modifier in their declaration are called static fields or class variables.  They are associated with the class, rather than with any object, hence can be manipulated without creating an instance of the class.  Methods having static modifier are invoked with the class name, without the need for creating an instance of class.  A common use for static methods is to access static fields.  Static methods cannot access instance variables or instance methods directly without an object reference.  Static methods cannot use the this keyword as there is no instance for this to refer to.
  • 23. Final keyword  The final modifier can be applied to four Java constructs:  variables: a final variable can be set once and only once, allowing to declare local constants. They must be assigned exactly once.  fields: a final field can also be set only once, by the constructor of the class which defines it.  methods: a final method cannot be overridden nor hidden.  classes: a final class cannot be extended. A final class has all its method declared final. On the other hand, fields of a final class do not have any special property.
  • 24. Final keyword continued  Final parameters are not considered part of the method signature, and are ignored by the compiler when resolving method calls.  Anonymous local classes can only reference local variables and parameters that are declared final.  Private and static methods are always implicitely final, since they cannot be overridden.