SlideShare une entreprise Scribd logo
1  sur  24
Chapter 1
Introduction to Object-Oriented
Programming
Outline
• Types of programming paradigm
• Overview of OO principles
• Overview of Java Programming and types of
Java Program
• Definition of Java Application, Java Applets
• Editing, Compiling and Interpreting
Types of programming paradigm
• The major programming paradigms:
– Imperative
– Logical
– Functional
– Object-Oriented
Types of programming paradigm (cont.)
Imperative
• assumes that the computer can maintain through
environments of variables any changes in a
computation process.
• Computations are performed through a guided
sequence of steps, in which these variables are
referred to or changed.
• The order of the steps is crucial, because a given step
will have different consequences depending on the
current values of variables when the step is executed.
“First do this and next do that”
Types of programming paradigm (cont.)
• There are two reasons for popularity:
– the imperative paradigm most closely resembles the actual
machine itself, so the programmer is much closer to the
machine.
– because of such closeness, the imperative paradigm was
the only one efficient enough for widespread use until
recently.
• Language representatives
– Fortran, Algol, Pascal, Basic, C
Types of programming paradigm (cont.)
• Advantages
– efficient;
– close to the machine;
– popular;
– familiar.
• Disadvantages
– The semantics of a program can be complex to understand
or prove;
– Debugging is harder;
– Abstraction is more limited than with some paradigms;
– Order is crucial, which doesn't always suit itself to
problems.
Types of programming paradigm (cont.)
Logical
• takes a declarative approach to problem-solving.
• Various logical assertions about a situation are
made, establishing all known facts. Then queries
are made.
• The role of the computer becomes maintaining
data and logical deduction.
“Answer a question via search for a solution”
Types of programming paradigm (cont.)
• Logical Paradigm Programming:
A logical program is divided into three sections:
– a series of definitions/declarations that define the problem domain
– statements of relevant facts
– statement of goals in the form of a query
• Any deducible solution to a query is returned. The definitions and
declarations are constructed entirely from relations. i.e. X is a member of
Y or X is in the internal between a and b etc.
• Advantages:
The advantages of logic oriented programming are bifold:
– The system solves the problem, so the programming steps themselves are kept to a
minimum;
– Proving the validity of a given program is simple.
Types of programming paradigm (cont.)
Functional
• views all subprograms as functions in the
mathematical sense-informally, they take in
arguments and return a single solution.
• The solution returned is based entirely on the
input.
“Evaluate an expression and use the resulting value for
something”
Types of programming paradigm (cont.)
Object-Oriented
• is a paradigm in which real-world objects are each viewed as
separate entities having their own state which is modified only by
built in procedures, called methods.
• Because objects operate independently, they are encapsulated into
modules which contain both local environments and methods.
• Communication with an object is done by message passing.
• Objects are organized into classes, from which they inherit methods
and equivalent variables.
• The object-oriented paradigm provides key benefits of reusable
code and code extensibility.
“Send messages between objects to simulate the temporal evolution of a
set of real world phenomena”
Types of programming paradigm (cont.)
Features & Benefits
• Data as well as operations are encapsulated in objects
• Information hiding is used to protect internal
properties of an object
• Inheritance gives OOP its chief benefit over other
programming paradigms - relatively easy code
reuse and extension without the need to change
existing source code.
• the derived class can also override behavior
corresponding to some of the methods of the base
class: there would be a different method to respond to
the same message.
Overview of OO principles
• In order for a programming language to
be object-oriented, it has to enable
working with classes and objects as well
as the implementation and use of the
fundamental object-oriented principles
and concepts: inheritance, abstraction,
encapsulation and polymorphism.
Overview of OO principles (cont.)
principles of OOP
• Encapsulation
– It is also called "information hiding".
– An object has to provide its users only with the essential
information for manipulation, without the internal details.
– A Secretary using a Laptop only knows about its screen,
keyboard and mouse. Everything else is hidden internally
under the cover. She does not know about the inner
workings of Laptop, because she doesn’t need to, and if
she does, she might make a mess. Therefore parts of the
properties and methods remain hidden to her.
Overview of OO principles (cont.)
• Inheritance
– It allows a class to "inherit" (behavior or
characteristics) of another, more general class.
– For example, a lion belongs to the biological family of
cats (Felidae). All cats that have four paws, are
predators and hunt their prey. This functionality can
be coded once in the Felidae class and all its predators
can reuse it
– Tiger, Puma, Bobcat, etc. Inheritance is described
as is-kind-of relationship, e.g. Tiger is kind of Animal.
Overview of OO principles(cont.)
• Abstraction
– means working with something we know how to
use without knowing how it works internally.
– A good example is a television set. We don’t need
to know the inner workings of a TV, in order to use
it. All we need is a remote control with a small set
of buttons (the interface of the remote) and we
will be able to watch TV.
Overview of OO principles(cont.)
• Polymorphism
– Polymorphism allows treating objects of a derived
class as objects of its base class.
– For example, big cats (base class) catch their prey
(a method) in different ways.
Overview of Java Programming and
types of Java Program
• Java programming language was originally developed by
Sun Microsystems which was initiated by James Gosling and
released in 1995 as core component of Sun Microsystems'
Java platform (Java 1.0 [J2SE]).
• The latest release of the Java Standard Edition is Java SE 8.
• With the advancement of Java and its widespread
popularity, multiple configurations were built to suit various
types of platforms. For example: J2EE for Enterprise
Applications, J2ME for Mobile Applications.
• The new J2 versions were renamed as Java SE, Java EE, and
Java ME respectively. Java is guaranteed to be Write Once,
Run Anywhere.
Overview of Java Programming(cont.)
Java is −
• Object Oriented − In Java, everything is an Object. Java can be easily extended
since it is based on the Object model.
• Platform Independent − Unlike many other programming languages including
C and C++, when Java is compiled, it is not compiled into platform specific
machine, rather into platform independent byte code. This byte code is
distributed over the web and interpreted by the Virtual Machine (JVM) on
whichever platform it is being run on.
• Simple − Java is designed to be easy to learn. If you understand the basic
concept of OOP Java, it would be easy to master.
• Secure − With Java's secure feature it enables to develop virus-free, tamper-
free systems. Authentication techniques are based on public-key encryption.
• Architecture-neutral − Java compiler generates an architecture-neutral object
file format, which makes the compiled code executable on many processors,
with the presence of Java runtime system.
Overview of Java Programming(cont.)
• Portable − Being architecture-neutral and having no implementation
dependent aspects of the specification makes Java portable.
• Robust − Java makes an effort to eliminate error prone situations by
emphasizing mainly on compile time error checking and runtime checking.
• Multithreaded − With Java's multithreaded feature it is possible to write
programs that can perform many tasks simultaneously.
• Interpreted − Java byte code is translated on the fly to native machine
instructions and is not stored anywhere.
• High Performance − With the use of Just-In-Time compilers, Java enables
high performance.
• Distributed − Java is designed for the distributed environment of the
internet.
• Dynamic − Java is considered to be more dynamic than C or C++ since it is
designed to adapt to an evolving environment.
Types of Java Program
• Java Applet - These are small programs written in java
and is usually stored on a website and is downloaded
and run on a client computer from within a web
browser
• Application - can only be run on the computer. If
online, it has to be downloaded before being run.
• Servlet - runs on a web server and helps to display web
pages.
• Swing application - is used to build an application that
has a GUI (windows, buttons, menus, etc.)
• EJB - runs on a web server and is used to develop large,
complex websites
Definition of Java Application, Java Applets
• Application is a Java class that has a main() method.
• An applet is a Java class which extends java.applet.Applet.
• Application is a stand-alone program, normally launched
from the command line, and which has unrestricted access
to the host system.
• An applet is a program which is run in the context of an
applet viewer or web browser, and which has strictly
limited access to the host system.
• For instance, an applet can normally not read or write files
on the host system whereas an application normally can.
• Applets may communicate with other applets running on
the same virtual machine.
Editing, Compiling and Interpreting
Editing
– all you need to write and edit Java code is a text
editor, such as the "NotePad" editor that we have
used to this point.
– each file must be saved under the
name classname.java
Compiling
• Before you can do anything with your Java code, you
have to compile it; "compiling" refers to the process by
which high-level, human-readable Java code is turned
into a long string of bytes (much like a machine language)
which can be understood by a Java interpreter.
Editing, Compiling and Interpreting (Cont.)
Interpreting
• "Interpreted" means that the computer looks at the
language, and then turns it into native machine language.
• The term Java interpreter refers to a program which
implements the JVM specification and actually executes the
bytecodes by running your program.
• Compiler versus Interpreter
• Compiling happens when the writing of the program is
finished like calling javac. Example:
– JAVAC Your_class_name.java
• Interpretation happens at runtime(which means while
running the Java program), Example:
– JAVA Your_class_name
object oriented programming examples

Contenu connexe

Tendances

Java buzzwords
Java buzzwordsJava buzzwords
Java buzzwordsramesh517
 
java training in jaipur|java training|core java training|java training compa...
 java training in jaipur|java training|core java training|java training compa... java training in jaipur|java training|core java training|java training compa...
java training in jaipur|java training|core java training|java training compa...infojaipurinfo Jaipur
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
Java OOP s concepts and buzzwords
Java OOP s concepts and buzzwordsJava OOP s concepts and buzzwords
Java OOP s concepts and buzzwordsRaja Sekhar
 
01 introduction to cpp
01   introduction to cpp01   introduction to cpp
01 introduction to cppManzoor ALam
 
Program logic and design
Program logic and designProgram logic and design
Program logic and designChaffey College
 
Python Programming
Python ProgrammingPython Programming
Python ProgrammingRenieMathews
 
Object Oriented Programming in Java
Object Oriented Programming in JavaObject Oriented Programming in Java
Object Oriented Programming in JavaHimanshiSingh71
 
Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)Kiran Jonnalagadda
 
Object Oriented programming - Introduction
Object Oriented programming - IntroductionObject Oriented programming - Introduction
Object Oriented programming - IntroductionMadishetty Prathibha
 

Tendances (20)

Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
Java buzzwords
Java buzzwordsJava buzzwords
Java buzzwords
 
java training in jaipur|java training|core java training|java training compa...
 java training in jaipur|java training|core java training|java training compa... java training in jaipur|java training|core java training|java training compa...
java training in jaipur|java training|core java training|java training compa...
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
Java OOP s concepts and buzzwords
Java OOP s concepts and buzzwordsJava OOP s concepts and buzzwords
Java OOP s concepts and buzzwords
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
 
01 introduction to cpp
01   introduction to cpp01   introduction to cpp
01 introduction to cpp
 
Program logic and design
Program logic and designProgram logic and design
Program logic and design
 
java token
java tokenjava token
java token
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
1 cc
1 cc1 cc
1 cc
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Object Oriented Programming in Java
Object Oriented Programming in JavaObject Oriented Programming in Java
Object Oriented Programming in Java
 
Features of java
Features of javaFeatures of java
Features of java
 
Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)
 
Java
JavaJava
Java
 
Java introduction
Java introductionJava introduction
Java introduction
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
 
Object Oriented programming - Introduction
Object Oriented programming - IntroductionObject Oriented programming - Introduction
Object Oriented programming - Introduction
 

Similaire à object oriented programming examples

JAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptJAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptAliyaJav
 
Unit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdUnit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdprat0ham
 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept Prakash Poudel
 
Programming using C++ - slides.pptx
Programming using C++ - slides.pptxProgramming using C++ - slides.pptx
Programming using C++ - slides.pptxHeadoftheDepartment
 
Lec 1-of-oop2
Lec 1-of-oop2Lec 1-of-oop2
Lec 1-of-oop2SM Rasel
 
java tutorial for beginners learning.ppt
java tutorial for beginners learning.pptjava tutorial for beginners learning.ppt
java tutorial for beginners learning.pptusha852
 
MWLUG - Universal Java
MWLUG  -  Universal JavaMWLUG  -  Universal Java
MWLUG - Universal JavaPhilippe Riand
 
Unit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptxUnit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptxshashiden1
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 
Programming language paradigms
Programming language paradigmsProgramming language paradigms
Programming language paradigmsAshok Raj
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptxmadan r
 
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingConcurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingSachintha Gunasena
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallJohn Mulhall
 

Similaire à object oriented programming examples (20)

JAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptJAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).ppt
 
Oop.pptx
Oop.pptxOop.pptx
Oop.pptx
 
Unit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdUnit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rd
 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept
 
Letest
LetestLetest
Letest
 
unit1.pptx
unit1.pptxunit1.pptx
unit1.pptx
 
Unit 2.pptx
Unit 2.pptxUnit 2.pptx
Unit 2.pptx
 
Unit 2.pptx
Unit 2.pptxUnit 2.pptx
Unit 2.pptx
 
Programming using C++ - slides.pptx
Programming using C++ - slides.pptxProgramming using C++ - slides.pptx
Programming using C++ - slides.pptx
 
Lec 1-of-oop2
Lec 1-of-oop2Lec 1-of-oop2
Lec 1-of-oop2
 
java tutorial for beginners learning.ppt
java tutorial for beginners learning.pptjava tutorial for beginners learning.ppt
java tutorial for beginners learning.ppt
 
MWLUG - Universal Java
MWLUG  -  Universal JavaMWLUG  -  Universal Java
MWLUG - Universal Java
 
Comp102 lec 3
Comp102   lec 3Comp102   lec 3
Comp102 lec 3
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
Unit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptxUnit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptx
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Programming language paradigms
Programming language paradigmsProgramming language paradigms
Programming language paradigms
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
 
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingConcurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
 

Plus de Abdii Rashid

object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examplesAbdii Rashid
 
Chapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for printChapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for printAbdii Rashid
 
Chapter 1 introduction haramaya
Chapter 1 introduction haramayaChapter 1 introduction haramaya
Chapter 1 introduction haramayaAbdii Rashid
 

Plus de Abdii Rashid (10)

Java chapter 7
Java chapter 7Java chapter 7
Java chapter 7
 
Java chapter 6
Java chapter 6Java chapter 6
Java chapter 6
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Java chapter 4
Java chapter 4Java chapter 4
Java chapter 4
 
Java chapter 3
Java chapter 3Java chapter 3
Java chapter 3
 
Java chapter 2
Java chapter 2Java chapter 2
Java chapter 2
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examples
 
Chapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for printChapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for print
 
Chapter 7 graphs
Chapter 7 graphsChapter 7 graphs
Chapter 7 graphs
 
Chapter 1 introduction haramaya
Chapter 1 introduction haramayaChapter 1 introduction haramaya
Chapter 1 introduction haramaya
 

Dernier

The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Christo Ananth
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 

Dernier (20)

The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 

object oriented programming examples

  • 1. Chapter 1 Introduction to Object-Oriented Programming
  • 2. Outline • Types of programming paradigm • Overview of OO principles • Overview of Java Programming and types of Java Program • Definition of Java Application, Java Applets • Editing, Compiling and Interpreting
  • 3. Types of programming paradigm • The major programming paradigms: – Imperative – Logical – Functional – Object-Oriented
  • 4. Types of programming paradigm (cont.) Imperative • assumes that the computer can maintain through environments of variables any changes in a computation process. • Computations are performed through a guided sequence of steps, in which these variables are referred to or changed. • The order of the steps is crucial, because a given step will have different consequences depending on the current values of variables when the step is executed. “First do this and next do that”
  • 5. Types of programming paradigm (cont.) • There are two reasons for popularity: – the imperative paradigm most closely resembles the actual machine itself, so the programmer is much closer to the machine. – because of such closeness, the imperative paradigm was the only one efficient enough for widespread use until recently. • Language representatives – Fortran, Algol, Pascal, Basic, C
  • 6. Types of programming paradigm (cont.) • Advantages – efficient; – close to the machine; – popular; – familiar. • Disadvantages – The semantics of a program can be complex to understand or prove; – Debugging is harder; – Abstraction is more limited than with some paradigms; – Order is crucial, which doesn't always suit itself to problems.
  • 7. Types of programming paradigm (cont.) Logical • takes a declarative approach to problem-solving. • Various logical assertions about a situation are made, establishing all known facts. Then queries are made. • The role of the computer becomes maintaining data and logical deduction. “Answer a question via search for a solution”
  • 8. Types of programming paradigm (cont.) • Logical Paradigm Programming: A logical program is divided into three sections: – a series of definitions/declarations that define the problem domain – statements of relevant facts – statement of goals in the form of a query • Any deducible solution to a query is returned. The definitions and declarations are constructed entirely from relations. i.e. X is a member of Y or X is in the internal between a and b etc. • Advantages: The advantages of logic oriented programming are bifold: – The system solves the problem, so the programming steps themselves are kept to a minimum; – Proving the validity of a given program is simple.
  • 9. Types of programming paradigm (cont.) Functional • views all subprograms as functions in the mathematical sense-informally, they take in arguments and return a single solution. • The solution returned is based entirely on the input. “Evaluate an expression and use the resulting value for something”
  • 10. Types of programming paradigm (cont.) Object-Oriented • is a paradigm in which real-world objects are each viewed as separate entities having their own state which is modified only by built in procedures, called methods. • Because objects operate independently, they are encapsulated into modules which contain both local environments and methods. • Communication with an object is done by message passing. • Objects are organized into classes, from which they inherit methods and equivalent variables. • The object-oriented paradigm provides key benefits of reusable code and code extensibility. “Send messages between objects to simulate the temporal evolution of a set of real world phenomena”
  • 11. Types of programming paradigm (cont.) Features & Benefits • Data as well as operations are encapsulated in objects • Information hiding is used to protect internal properties of an object • Inheritance gives OOP its chief benefit over other programming paradigms - relatively easy code reuse and extension without the need to change existing source code. • the derived class can also override behavior corresponding to some of the methods of the base class: there would be a different method to respond to the same message.
  • 12. Overview of OO principles • In order for a programming language to be object-oriented, it has to enable working with classes and objects as well as the implementation and use of the fundamental object-oriented principles and concepts: inheritance, abstraction, encapsulation and polymorphism.
  • 13. Overview of OO principles (cont.) principles of OOP • Encapsulation – It is also called "information hiding". – An object has to provide its users only with the essential information for manipulation, without the internal details. – A Secretary using a Laptop only knows about its screen, keyboard and mouse. Everything else is hidden internally under the cover. She does not know about the inner workings of Laptop, because she doesn’t need to, and if she does, she might make a mess. Therefore parts of the properties and methods remain hidden to her.
  • 14. Overview of OO principles (cont.) • Inheritance – It allows a class to "inherit" (behavior or characteristics) of another, more general class. – For example, a lion belongs to the biological family of cats (Felidae). All cats that have four paws, are predators and hunt their prey. This functionality can be coded once in the Felidae class and all its predators can reuse it – Tiger, Puma, Bobcat, etc. Inheritance is described as is-kind-of relationship, e.g. Tiger is kind of Animal.
  • 15. Overview of OO principles(cont.) • Abstraction – means working with something we know how to use without knowing how it works internally. – A good example is a television set. We don’t need to know the inner workings of a TV, in order to use it. All we need is a remote control with a small set of buttons (the interface of the remote) and we will be able to watch TV.
  • 16. Overview of OO principles(cont.) • Polymorphism – Polymorphism allows treating objects of a derived class as objects of its base class. – For example, big cats (base class) catch their prey (a method) in different ways.
  • 17. Overview of Java Programming and types of Java Program • Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java 1.0 [J2SE]). • The latest release of the Java Standard Edition is Java SE 8. • With the advancement of Java and its widespread popularity, multiple configurations were built to suit various types of platforms. For example: J2EE for Enterprise Applications, J2ME for Mobile Applications. • The new J2 versions were renamed as Java SE, Java EE, and Java ME respectively. Java is guaranteed to be Write Once, Run Anywhere.
  • 18. Overview of Java Programming(cont.) Java is − • Object Oriented − In Java, everything is an Object. Java can be easily extended since it is based on the Object model. • Platform Independent − Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by the Virtual Machine (JVM) on whichever platform it is being run on. • Simple − Java is designed to be easy to learn. If you understand the basic concept of OOP Java, it would be easy to master. • Secure − With Java's secure feature it enables to develop virus-free, tamper- free systems. Authentication techniques are based on public-key encryption. • Architecture-neutral − Java compiler generates an architecture-neutral object file format, which makes the compiled code executable on many processors, with the presence of Java runtime system.
  • 19. Overview of Java Programming(cont.) • Portable − Being architecture-neutral and having no implementation dependent aspects of the specification makes Java portable. • Robust − Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking. • Multithreaded − With Java's multithreaded feature it is possible to write programs that can perform many tasks simultaneously. • Interpreted − Java byte code is translated on the fly to native machine instructions and is not stored anywhere. • High Performance − With the use of Just-In-Time compilers, Java enables high performance. • Distributed − Java is designed for the distributed environment of the internet. • Dynamic − Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment.
  • 20. Types of Java Program • Java Applet - These are small programs written in java and is usually stored on a website and is downloaded and run on a client computer from within a web browser • Application - can only be run on the computer. If online, it has to be downloaded before being run. • Servlet - runs on a web server and helps to display web pages. • Swing application - is used to build an application that has a GUI (windows, buttons, menus, etc.) • EJB - runs on a web server and is used to develop large, complex websites
  • 21. Definition of Java Application, Java Applets • Application is a Java class that has a main() method. • An applet is a Java class which extends java.applet.Applet. • Application is a stand-alone program, normally launched from the command line, and which has unrestricted access to the host system. • An applet is a program which is run in the context of an applet viewer or web browser, and which has strictly limited access to the host system. • For instance, an applet can normally not read or write files on the host system whereas an application normally can. • Applets may communicate with other applets running on the same virtual machine.
  • 22. Editing, Compiling and Interpreting Editing – all you need to write and edit Java code is a text editor, such as the "NotePad" editor that we have used to this point. – each file must be saved under the name classname.java Compiling • Before you can do anything with your Java code, you have to compile it; "compiling" refers to the process by which high-level, human-readable Java code is turned into a long string of bytes (much like a machine language) which can be understood by a Java interpreter.
  • 23. Editing, Compiling and Interpreting (Cont.) Interpreting • "Interpreted" means that the computer looks at the language, and then turns it into native machine language. • The term Java interpreter refers to a program which implements the JVM specification and actually executes the bytecodes by running your program. • Compiler versus Interpreter • Compiling happens when the writing of the program is finished like calling javac. Example: – JAVAC Your_class_name.java • Interpretation happens at runtime(which means while running the Java program), Example: – JAVA Your_class_name