SlideShare une entreprise Scribd logo
1  sur  24
Basic Object-Oriented Approach
Jigar Jobanputra
Jigar Jobanputra(JJ)
Session Objectives
 Discuss the object oriented approach
 Discuss the drawbacks of traditional
programming
 Discuss object oriented programming
 Discuss basic Object-Oriented concepts such as
objects, classes, properties, methods, abstraction,
inheritance, encapsulation, reusability and
polymorphism.
 Describe Java Virtual Machine
 Write the First Java Program
Jigar Jobanputra(JJ)
The Object-Oriented Approach
PersonnelAccounts
Sales
The real world around is full of objects .We can consider both the living
beings as well as non living elements as objects.
For example, the different departments in a company are objects.
Jigar Jobanputra(JJ)
Drawbacks of Traditional
Programming
 Unmanageable programs
 Problems in modification of data
 Difficulty in implementation
Jigar Jobanputra(JJ)
Object – Oriented
Programming
Data
Employee details
Salary statements
Bills
Vouchers
Receipts
Functions
Calculate salary
Pay salary
Pay bills
Tally accounts
Transact with banks
Here the application has to implement the entities as they are seen in real life and
associate their actions and attributes with each other.
Accounts
Jigar Jobanputra(JJ)
Objects
Some real-life entities :
 Physical Objects
 Vehicles in a traffic -monitoring application
 Electrical components in a circuit design problem
 Elements of the computer-user environment
 Windows
 Menus
An object is an element with defined boundaries that is relevant to the problem we
are dealing with
Jigar Jobanputra(JJ)
Objects (contd…)
 Collections of data
 An inventory of machine parts
 A personnel file
 User defined data types
 Time
 Angles
 Complex numbers
Jigar Jobanputra(JJ)
Objects (contd…)
Model : Ferrari
Color : Red
Year : 1995
Actions
Start
Stop
Accelerate
Jigar Jobanputra(JJ)
Classes
A class is a group of objects that have the same properties, common behavior.
Polygon objects Polygon class
Properties
Vertices
Border color
Fill color
Methods
Draw
Erase
Move
Jigar Jobanputra(JJ)
Encapsulation
Encapsulation is a process that allows
selective hiding of properties and
methods in a class.
Not accessible from outside
class
Accessible from outside class
Private
Public
Jigar Jobanputra(JJ)
Inheritance
Inheritance is the property that allows the reuse of an existing class to build a
new class
Animals
Jigar Jobanputra(JJ)
Abstraction
Attributes
Methods
Class
Data abstraction is a process
of identifying properties and
methods related much to a
particular entity as relevant to
the application
Jigar Jobanputra(JJ)
Reusability
Make sounds
Eat and drink
Hunt prey
Mew
Drink milk
Hunt mice
Roar
Eat flesh
Hunt big game
Felines
Jigar Jobanputra(JJ)
Polymorphism
Subclasses
Polymorphism allows same method to behave differently on different classes.
Class : Shape
Methods :
Draw
Move
Initialize
Jigar Jobanputra(JJ)
Object – Oriented Languages
 C ++
 Small Talk
 Eiffel
 CLOS
 Java
Jigar Jobanputra(JJ)
The Problem with High Level
Language
P
R
O
B
L
E
M
Program
Applications
written for a
particular
platform will not
work on another
platform
S
O
L
U
T
I
O
N
Interpreter
Interpreter
Interpreter
Program To solve this
problem, we
make use of
interpreters
So the code for any application can be written only once, which can then be
executed with the help of Interpreters created for different platformsJigar Jobanputra(JJ)
Java Language
 Java is a language from SUN Microsystems.
 Java uses an Interpreter to execute code so that it may run on different
computers without any change to the source code.
 Java Programs are platform independent. Hence the code written in Java can be
executed on different platforms.
 Java is a program mainly used for Web based applications because of its
support to different platforms.
 Java is purely an Object Oriented Programming language.
Jigar Jobanputra(JJ)
Java Virtual Machine (JVM)
Source Code
Imaginary computer’s
instruction set
Compiler
Target Machine
Java Virtual Machine
For each computer, there is a unique Java Virtual Machine
Machine language code
Byte Code
Jigar Jobanputra(JJ)
Life Cycle of a Java Program
Compiler Filename.class
Byte Code
Filename.java
Source Code
User
Code
Java Virtual Machine
Jigar Jobanputra(JJ)
Execution procedure by the JVM
The Java Virtual Machine creates a runtime system
internally that helps the execution of code by :
Loading the “ . class ” files.
Managing the memory.
Performing Garbage collection.
Jigar Jobanputra(JJ)
Java code and JVM
 All java programs are written keeping in mind the
Java VM.
 The Java source code and the byte code is machine
independent while JVM is machine dependant.
 Different machines with different Operating system
will require a JVM developed for that machine.
Jigar Jobanputra(JJ)
First Program
class HelloJava
{
public static void main( String args[])
{
System.out.println(“Welcome to the
world of Java”);
}
}
Jigar Jobanputra(JJ)
First Program [Contd…]
• Save the file as HelloJava.java
• Use the javac command to compile the
file HelloJava.java
• Execute the bytecodes of
HelloJava.class using the java
command
Jigar Jobanputra(JJ)
Thank You
Jigar Jobanputra(JJ)

Contenu connexe

Tendances

Tendances (13)

the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented Programming
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
javaopps concepts
javaopps conceptsjavaopps concepts
javaopps concepts
 
[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Object Oriented Programming Languages
Object Oriented Programming LanguagesObject Oriented Programming Languages
Object Oriented Programming Languages
 
OOPs concept and implementation
OOPs concept and implementationOOPs concept and implementation
OOPs concept and implementation
 
Cs8392 oops 5 units notes
Cs8392 oops 5 units notes Cs8392 oops 5 units notes
Cs8392 oops 5 units notes
 
[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects
 
Java oo ps concepts
Java oo ps conceptsJava oo ps concepts
Java oo ps concepts
 
Oop basic overview
Oop basic overviewOop basic overview
Oop basic overview
 
Object Oriented Concepts in Real Projects
Object Oriented Concepts in Real ProjectsObject Oriented Concepts in Real Projects
Object Oriented Concepts in Real Projects
 
ITFT - Oops
ITFT - OopsITFT - Oops
ITFT - Oops
 

En vedette

Object Oriented Approach for Software Development
Object Oriented Approach for Software DevelopmentObject Oriented Approach for Software Development
Object Oriented Approach for Software DevelopmentRishabh Soni
 
Review of object orientation
Review of object orientationReview of object orientation
Review of object orientationGurbakash Phonsa
 
01 concepts of_object-orientation (1)
01 concepts of_object-orientation (1)01 concepts of_object-orientation (1)
01 concepts of_object-orientation (1)AaDi RA
 
Object oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageObject oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageIsmail El Gayar
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisMahesh Bhalerao
 
Object oriented methodologies
Object oriented methodologiesObject oriented methodologies
Object oriented methodologiesnaina-rani
 
Structured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and DesignStructured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and DesignMotaz Saad
 
Requirement elicitation
Requirement elicitationRequirement elicitation
Requirement elicitationvivacemente
 
Object oriented software engineering concepts
Object oriented software engineering conceptsObject oriented software engineering concepts
Object oriented software engineering conceptsKomal Singh
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and DesignHaitham El-Ghareeb
 

En vedette (11)

Object Oriented Approach for Software Development
Object Oriented Approach for Software DevelopmentObject Oriented Approach for Software Development
Object Oriented Approach for Software Development
 
Review of object orientation
Review of object orientationReview of object orientation
Review of object orientation
 
01 concepts of_object-orientation (1)
01 concepts of_object-orientation (1)01 concepts of_object-orientation (1)
01 concepts of_object-orientation (1)
 
Object oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageObject oriented methodology & unified modeling language
Object oriented methodology & unified modeling language
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented methodologies
Object oriented methodologiesObject oriented methodologies
Object oriented methodologies
 
Online shopping
Online shoppingOnline shopping
Online shopping
 
Structured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and DesignStructured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and Design
 
Requirement elicitation
Requirement elicitationRequirement elicitation
Requirement elicitation
 
Object oriented software engineering concepts
Object oriented software engineering conceptsObject oriented software engineering concepts
Object oriented software engineering concepts
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
 

Similaire à Basic object oriented approach

What are the different java interview questions you need to know?
What are the different java interview questions you need to know?What are the different java interview questions you need to know?
What are the different java interview questions you need to know?kanchanmahajan23
 
What are the different java interview questions you need to know?
What are the different java interview questions you need to know?What are the different java interview questions you need to know?
What are the different java interview questions you need to know?kanchanmahajan23
 
A seminar report on core java
A  seminar report on core javaA  seminar report on core java
A seminar report on core javaAisha Siddiqui
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSujit Majety
 
Java essentials for hadoop
Java essentials for hadoopJava essentials for hadoop
Java essentials for hadoopSeo Gyansha
 
User Stories for your Product Backlog
User Stories for your Product BacklogUser Stories for your Product Backlog
User Stories for your Product Backlogrwirdemann
 
Introducing Android Programming
Introducing Android ProgrammingIntroducing Android Programming
Introducing Android ProgrammingArif Huda
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java MayaTofik
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating guiViên Mai
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java LanguagePawanMM
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to JavaDevaKumari Vijay
 
Expens-O-Meter, a web based tool built using Ruby on Rails
Expens-O-Meter, a web based tool built using Ruby on RailsExpens-O-Meter, a web based tool built using Ruby on Rails
Expens-O-Meter, a web based tool built using Ruby on Railsjatinder
 

Similaire à Basic object oriented approach (20)

What are the different java interview questions you need to know?
What are the different java interview questions you need to know?What are the different java interview questions you need to know?
What are the different java interview questions you need to know?
 
What are the different java interview questions you need to know?
What are the different java interview questions you need to know?What are the different java interview questions you need to know?
What are the different java interview questions you need to know?
 
A seminar report on core java
A  seminar report on core javaA  seminar report on core java
A seminar report on core java
 
3. jvm
3. jvm3. jvm
3. jvm
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java essentials for hadoop
Java essentials for hadoopJava essentials for hadoop
Java essentials for hadoop
 
Java essentials for hadoop
Java essentials for hadoopJava essentials for hadoop
Java essentials for hadoop
 
Java presentation
Java presentation Java presentation
Java presentation
 
User Stories for your Product Backlog
User Stories for your Product BacklogUser Stories for your Product Backlog
User Stories for your Product Backlog
 
Introducing Android Programming
Introducing Android ProgrammingIntroducing Android Programming
Introducing Android Programming
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Expens-O-Meter, a web based tool built using Ruby on Rails
Expens-O-Meter, a web based tool built using Ruby on RailsExpens-O-Meter, a web based tool built using Ruby on Rails
Expens-O-Meter, a web based tool built using Ruby on Rails
 
Java basic
Java basicJava basic
Java basic
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
 
Chap06
Chap06Chap06
Chap06
 

Plus de Jigarthacker (13)

File mangement
File mangementFile mangement
File mangement
 
Java session14
Java session14Java session14
Java session14
 
Java session13
Java session13Java session13
Java session13
 
Java session5
Java session5Java session5
Java session5
 
Java session4
Java session4Java session4
Java session4
 
Java session3
Java session3Java session3
Java session3
 
Java session2
Java session2Java session2
Java session2
 
Computer networks
Computer networksComputer networks
Computer networks
 
Unit 2
Unit 2Unit 2
Unit 2
 
Unit 1(sem-iv)
Unit 1(sem-iv)Unit 1(sem-iv)
Unit 1(sem-iv)
 
Unit 2
Unit 2Unit 2
Unit 2
 
Unit 1
Unit 1Unit 1
Unit 1
 
C programming
C programmingC programming
C programming
 

Dernier

VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 

Dernier (20)

VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 

Basic object oriented approach

  • 1. Basic Object-Oriented Approach Jigar Jobanputra Jigar Jobanputra(JJ)
  • 2. Session Objectives  Discuss the object oriented approach  Discuss the drawbacks of traditional programming  Discuss object oriented programming  Discuss basic Object-Oriented concepts such as objects, classes, properties, methods, abstraction, inheritance, encapsulation, reusability and polymorphism.  Describe Java Virtual Machine  Write the First Java Program Jigar Jobanputra(JJ)
  • 3. The Object-Oriented Approach PersonnelAccounts Sales The real world around is full of objects .We can consider both the living beings as well as non living elements as objects. For example, the different departments in a company are objects. Jigar Jobanputra(JJ)
  • 4. Drawbacks of Traditional Programming  Unmanageable programs  Problems in modification of data  Difficulty in implementation Jigar Jobanputra(JJ)
  • 5. Object – Oriented Programming Data Employee details Salary statements Bills Vouchers Receipts Functions Calculate salary Pay salary Pay bills Tally accounts Transact with banks Here the application has to implement the entities as they are seen in real life and associate their actions and attributes with each other. Accounts Jigar Jobanputra(JJ)
  • 6. Objects Some real-life entities :  Physical Objects  Vehicles in a traffic -monitoring application  Electrical components in a circuit design problem  Elements of the computer-user environment  Windows  Menus An object is an element with defined boundaries that is relevant to the problem we are dealing with Jigar Jobanputra(JJ)
  • 7. Objects (contd…)  Collections of data  An inventory of machine parts  A personnel file  User defined data types  Time  Angles  Complex numbers Jigar Jobanputra(JJ)
  • 8. Objects (contd…) Model : Ferrari Color : Red Year : 1995 Actions Start Stop Accelerate Jigar Jobanputra(JJ)
  • 9. Classes A class is a group of objects that have the same properties, common behavior. Polygon objects Polygon class Properties Vertices Border color Fill color Methods Draw Erase Move Jigar Jobanputra(JJ)
  • 10. Encapsulation Encapsulation is a process that allows selective hiding of properties and methods in a class. Not accessible from outside class Accessible from outside class Private Public Jigar Jobanputra(JJ)
  • 11. Inheritance Inheritance is the property that allows the reuse of an existing class to build a new class Animals Jigar Jobanputra(JJ)
  • 12. Abstraction Attributes Methods Class Data abstraction is a process of identifying properties and methods related much to a particular entity as relevant to the application Jigar Jobanputra(JJ)
  • 13. Reusability Make sounds Eat and drink Hunt prey Mew Drink milk Hunt mice Roar Eat flesh Hunt big game Felines Jigar Jobanputra(JJ)
  • 14. Polymorphism Subclasses Polymorphism allows same method to behave differently on different classes. Class : Shape Methods : Draw Move Initialize Jigar Jobanputra(JJ)
  • 15. Object – Oriented Languages  C ++  Small Talk  Eiffel  CLOS  Java Jigar Jobanputra(JJ)
  • 16. The Problem with High Level Language P R O B L E M Program Applications written for a particular platform will not work on another platform S O L U T I O N Interpreter Interpreter Interpreter Program To solve this problem, we make use of interpreters So the code for any application can be written only once, which can then be executed with the help of Interpreters created for different platformsJigar Jobanputra(JJ)
  • 17. Java Language  Java is a language from SUN Microsystems.  Java uses an Interpreter to execute code so that it may run on different computers without any change to the source code.  Java Programs are platform independent. Hence the code written in Java can be executed on different platforms.  Java is a program mainly used for Web based applications because of its support to different platforms.  Java is purely an Object Oriented Programming language. Jigar Jobanputra(JJ)
  • 18. Java Virtual Machine (JVM) Source Code Imaginary computer’s instruction set Compiler Target Machine Java Virtual Machine For each computer, there is a unique Java Virtual Machine Machine language code Byte Code Jigar Jobanputra(JJ)
  • 19. Life Cycle of a Java Program Compiler Filename.class Byte Code Filename.java Source Code User Code Java Virtual Machine Jigar Jobanputra(JJ)
  • 20. Execution procedure by the JVM The Java Virtual Machine creates a runtime system internally that helps the execution of code by : Loading the “ . class ” files. Managing the memory. Performing Garbage collection. Jigar Jobanputra(JJ)
  • 21. Java code and JVM  All java programs are written keeping in mind the Java VM.  The Java source code and the byte code is machine independent while JVM is machine dependant.  Different machines with different Operating system will require a JVM developed for that machine. Jigar Jobanputra(JJ)
  • 22. First Program class HelloJava { public static void main( String args[]) { System.out.println(“Welcome to the world of Java”); } } Jigar Jobanputra(JJ)
  • 23. First Program [Contd…] • Save the file as HelloJava.java • Use the javac command to compile the file HelloJava.java • Execute the bytecodes of HelloJava.class using the java command Jigar Jobanputra(JJ)