SlideShare une entreprise Scribd logo
1  sur  48
Programming With JAVA 
OOP & JAVA Overview 
By: 
Sneha M 
M.Sc. (Software Technology)
Overview 
 Introduction to OOP 
 Characteristics of OOP
Introduction to OOP 
 OOP is an approach to program organization and 
development, which attempts to eliminate some of 
the pitfalls of programming methods. 
 It is by incorporating the best of structured 
programming features with several new concepts.
Characteristics of OOP 
 Data Abstraction and Encapsulation 
 Inheritance 
 Polymorphism 
 Dynamic Binding 
 Message Communication
Data Abstraction and Encapsulation 
 Encapsulation : The wrapping up of data and method 
in to a single units. (Data can be accessed by the 
methods which are inside the class) 
 Methods provide interface between objects data and 
the program. 
 Data Hiding : The insulation of the data from the 
direct access by the program. 
 Abstraction : Act of representing the essential 
features with out including the background details.
Inheritance 
 Process by which object of one class acquires the 
properties of another class. 
 Hierarchical classification. 
 Reusability 
- adding additional features without modifying it. 
-deriving new class (sub class) from existing one. 
-new class will have combined features of both 
the classes.
Polymorphism 
 Ability to take more than one form. 
 Ex: Operation of addition. 
- for 2 numbers as operands, the 
operation will generate a SUM. 
- for 2 strings as operands, the 
operation would produce a third 
string by concatenation.
Dynamic Binding 
 Binding -Linking of procedure call to the code to be 
executed in response to the call. 
 Dynamic Binding – code associated with a given 
procedure call is not known until the time of the call 
at runtime. 
 Associated with polymorphism & inheritance.
Message Communication. 
 The process of programming in OO Language involves 2 
basic steps : 
1. Creating Classes – define objects and their behaviour. 
2. Creating Objects from class definitions. 
3. Establishing communication among objects. 
Ex: Employee.salary(name); 
Employee – object 
Salary – message 
Name – parameter that contains information.
Benefits of OOP 
• Inheritance – Eliminate code and extend the use of existing class. 
• Data Hiding - Helps the programmer to build secure program. 
• Objects – Easy to partition program. 
• Object oriented system can be easily upgraded.
Overview of JAVA Language. 
 Introduction 
 Writing JAVA Program 
 Implementing JAVA Program 
 JVM 
 JAVA Tokens 
 Command Line Arguments.
 JAVA is a general purpose OOP language. 
 We can develop two types of JAVA programs : 
- Standalone applications 
-Web Applets 
 Executing a standalone JAVA Program involves 2 steps: 
1. Compiling source code into byte code using javac compiler. 
2. Executing byte code program using java interpreter. 
 Applets are small java programs developed for Internet 
applications 
Introduction
Two ways of using JAVA 
Java Source Code 
Written in java 
to carry out 
certain task 
Located on 
server can be 
downloaded and 
executed 
Applets Type Application Type 
Java Enabled Web 
browser 
Java 
Interpreter 
Java 
Compiler 
Output Output
Two ways of using JAVA 
Java Source Code 
Applets Type Application Type 
Java Enabled Web 
browser 
Java 
Interpreter 
Java 
Compiler 
Output Output
Two ways of using JAVA 
Java Source Code 
Applets Type Application Type 
Java Enabled Web 
browser 
Java 
Interpreter 
Java 
Compiler 
Output Output
Two ways of using JAVA 
Java Source Code 
Applets Type Application Type 
Java Enabled Web 
browser 
Java 
Interpreter 
Java 
Compiler 
Output Output
Writing a JAVA Program
OUTPUT
Explanation.. 
 Class Declaration – 
class P1 – declares class - object oriented construct. 
 Class is a keyword 
 P1 is a java identifier- specifies name of the class. 
 The main line – 
public static void main(String[] args) 
 main – method 
 Starting point for the interpreter to begin execution of the 
program. 
 A java application can have any no.of classes but only one of 
them must include a main method to initiate the execution. 
 Applet does not use the main method.
public static void main(String[] args) 
 Public: 
 An access specifier that declares the main method as unprotected 
and therefore making it accessible to all other classes. 
 Static: 
 Declares the method as one that belongs to entire class and not a 
part of any objects of a class. 
 Since the interpreter uses main method before any objects are 
created, it must be always be declared as static. 
 Void: 
 Type modifier states that the main does not return any value. 
 All parameters to a method are declared inside a pair of parenthesis. 
 String[] args: 
 Declares a parameter named args, which contain an array of objects 
of the class type string.
Java Program Structure 
Documentation Section 
•Comprises a set of comment lines. 
•/*..*/ known as documentation comment 
Package Statement 
• First statement allowed in java file. 
• Declares Package name and inform compiler that 
classes defined here belong to this package. 
Import Statements 
•Comes next to package statement but before any class declarations. 
•Import student.test – instructs the interpreter to load the test class 
contained the package student.So we can have access to classes that 
are the part of other named packages.
Contd.. 
Interface Statements 
•It is like class but includes a group of method 
declarations which is optional section and is used only 
when we wish to implement multiple inheritance. 
•New concept in java. 
Class Definitions 
•A java program may contain multiple class definitions. 
•Classes are essential and primary elements of java program. 
•The number of classes used depends on the complexity of the 
problem. 
Main method class 
•The main method creates objects of different classes 
and establishes communication between them. 
•On reaching the end of the main, program terminates 
and control passes back to the OS.
Implementing a JAVA Program 
 Creating the program 
 Compiling the program 
 Running the program
Creating the program 
 The file is called sourcefile. It has extension .java. 
 If a program contain multiple classes, the file name must be the class name of the 
class containing the main method.
Compiling the Program 
 To compile the program we must run the java 
compiler javac, with the name of the source file on the 
command line – 
javac P1.java 
 If there is no error it automatically creates a file called 
P1.class i.e., the byte code file containing the byte 
codes of the program- 
<classname>.class
Running a Program 
 Here we need to use the java interpreter to run the 
standalone program. 
 At command prompt type 
Java P1 
Machine Neutral 
Compiler converts source code files in to bytecode 
files which are machine independent and therefore can be 
run on any machine. 
Java interpreter reads the byte code files and 
translates them into machine code for specific machine on 
which java program is running.
JAVA Virtual Machine 
 Java compiler produces an intermedia code known as 
byte code for machine that does not exist. 
 This machine is called JVM and it exists only inside the 
computer memory. 
 It is a simulated computer within the computer and 
does all the major functions of a real computer.
Process of compilation 
Java Program Java Compiler Virtual Machine 
Source Code Byte Code 
Byte Code Java Interpreter Machine Code 
Virtual Machine Real Machine
Process of compilation 
Java Program Java Compiler Virtual Machine 
Source Code Byte Code 
Byte Code Java Interpreter Machine Code 
Virtual Machine Real Machine
Process of compilation 
Java Program Java Compiler Virtual Machine 
Source Code Byte Code 
Byte Code Java Interpreter Machine Code 
Virtual Machine Real Machine
Process of compilation 
Java Program Java Compiler Virtual Machine 
Source Code Byte Code 
Byte Code Java Interpreter Machine Code 
Virtual Machine Real Machine
Process of compilation 
Java Program Java Compiler Virtual Machine 
Source Code Byte Code 
Byte Code Java Interpreter Machine Code 
Virtual Machine Real Machine
Process of compilation 
Java Program Java Compiler Virtual Machine 
Source Code Byte Code 
Byte Code Java Interpreter Machine Code 
Virtual Machine Real Machine
JAVA Tokens 
 A java program is basically a collection of classes. 
 A class is defined by set of declaration statements and 
methods containing executable statements. 
 Smallest individual units in a program is known as 
tokens. 
 Java language includes 5 types of tokens : 
 Reserved Keywords 
 Identifiers 
 Literals 
 Operators 
 Separators
 Programmer designed tokens. 
 They are used for – Naming 
1. classes 
2. Methods 
3. Variables 
4. Objects 
5. Labels 
6. Packages 
7. Interfaces 
Identifiers
Rules followed by Identifiers 
1. They can have alphabets, digits, underscore and 
dollar sign characters. 
2. They must not begin with a digit. 
3. Uppercase and lowercase letters are distinct. 
4. They can be of any length.
Command Line Arguments 
 Parameters that are supplied to the application program at the time 
of invoking it for execution. 
Ex : 
java P1 BASIC FORTRAN C++ Java 
It consists four arguments. These are assigned to the array args as 
follows: 
args[0]->BASIC 
args[1]->FORTRAN 
args[2]->C++ 
args[3]->Java
Program
Contd..
Use of Math Functions 
 import java.lang.Math; 
The purpose of this statement to instruct the 
interpreter to load the Math class from the package 
lang. 
 The examples discussed uses only one class that uses 
the main method. 
 A real life application will generally requires multiple 
classes.
Program defining 2 classes
Classes & Objects 
 Underlying structure of all java programs is classes. 
 Classes create objects and objects use methods to 
communicate between them. 
 Classes provide convenient method for packing 
together a group of logically related data items and 
functions that work on them. 
 In java data items are called fields and the functions 
are called methods.
 Class classname [ extends superclassname] 
{ 
[variable declaration;] 
[method declaration;] 
} 
Defining a Class
Adding Data Fields, Method to class 
and creating objects
Constructors. 
 Constructors enables an object to initialize itself when 
it is created. 
 Constructors are methods of class having same name 
as that of class name and used to initialize instance 
variables of the class. 
 They do not specify any return type not even void due 
to they return instance of the class itself.
Program using Constructors
 Creating methods that have same name but with different parameter lists and different definitions. 
 Ex: 
class Rectangl 
{ 
int length, width; 
//CONSTRUCTOR 
Rooml(int x, int y) 
{ 
length= x; 
width = y; 
} 
Rooml(int x, int y) 
{ 
length=width= x; 
} 
int recArea() 
{ 
int area = length*width; 
return(area); 
} 
Method Overloading
Inheritance

Contenu connexe

Tendances

Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming pptNitesh Dubey
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazationSiva Sathya
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Procedure oriented programming
Procedure oriented programmingProcedure oriented programming
Procedure oriented programmingMrShahbazRafiq
 
File handling in c
File handling in cFile handling in c
File handling in caakanksha s
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS ConceptBoopathi K
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vbSalim M
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingIqra khalil
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and PackagesDamian T. Gordon
 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In JavaMD SALEEM QAISAR
 

Tendances (20)

Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming ppt
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Interfaces .net
Interfaces .netInterfaces .net
Interfaces .net
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazation
 
Oop
OopOop
Oop
 
concept of oops
concept of oopsconcept of oops
concept of oops
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Procedure oriented programming
Procedure oriented programmingProcedure oriented programming
Procedure oriented programming
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and Packages
 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In Java
 

En vedette

Java Stack Traces
Java Stack TracesJava Stack Traces
Java Stack Tracesdbanttari
 
Linked list (java platform se 8 )
Linked list (java platform se 8 )Linked list (java platform se 8 )
Linked list (java platform se 8 )charan kumar
 
Heap and stack space in java
Heap and stack space in javaHeap and stack space in java
Heap and stack space in javaTalha Ocakçı
 
03 Java Language And OOP Part III
03 Java Language And OOP Part III03 Java Language And OOP Part III
03 Java Language And OOP Part IIIHari Christian
 
Java Collections Framework Inroduction with Video Tutorial
Java Collections Framework Inroduction with Video TutorialJava Collections Framework Inroduction with Video Tutorial
Java Collections Framework Inroduction with Video TutorialMarcus Biel
 
JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)Prof. Erwin Globio
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operationSenthil Kumar
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectOUM SAOKOSAL
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programmingSachin Sharma
 

En vedette (20)

Java Stack Traces
Java Stack TracesJava Stack Traces
Java Stack Traces
 
Linked list (java platform se 8 )
Linked list (java platform se 8 )Linked list (java platform se 8 )
Linked list (java platform se 8 )
 
Heap and stack space in java
Heap and stack space in javaHeap and stack space in java
Heap and stack space in java
 
Java Stack (Pilha)
Java Stack (Pilha)Java Stack (Pilha)
Java Stack (Pilha)
 
Introduction to java and oop
Introduction to java and oopIntroduction to java and oop
Introduction to java and oop
 
03 Java Language And OOP Part III
03 Java Language And OOP Part III03 Java Language And OOP Part III
03 Java Language And OOP Part III
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
01 introduction to oop and java
01 introduction to oop and java01 introduction to oop and java
01 introduction to oop and java
 
Java Collections Framework Inroduction with Video Tutorial
Java Collections Framework Inroduction with Video TutorialJava Collections Framework Inroduction with Video Tutorial
Java Collections Framework Inroduction with Video Tutorial
 
Stack, queue and hashing
Stack, queue and hashingStack, queue and hashing
Stack, queue and hashing
 
JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Oop java
Oop javaOop java
Oop java
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operation
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and Object
 
OOP java
OOP javaOOP java
OOP java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 

Similaire à JAVA OOP & Programming Guide

Java for Mainframers
Java for MainframersJava for Mainframers
Java for MainframersRich Helton
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to JavaSMIJava
 
Unit of competency
Unit of competencyUnit of competency
Unit of competencyloidasacueza
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfUmesh Kumar
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2Techglyphs
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruNithin Kumar,VVCE, Mysuru
 
Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 
Java-1st.pptx about Java technology before oops
Java-1st.pptx about Java technology before oopsJava-1st.pptx about Java technology before oops
Java-1st.pptx about Java technology before oopsbuvanabala
 

Similaire à JAVA OOP & Programming Guide (20)

Java notes
Java notesJava notes
Java notes
 
Java1
Java1Java1
Java1
 
Java
Java Java
Java
 
JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program Examples
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
 
Introduction to Core Java Programming
Introduction to Core Java ProgrammingIntroduction to Core Java Programming
Introduction to Core Java Programming
 
Mpl 1
Mpl 1Mpl 1
Mpl 1
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Java introduction
Java introductionJava introduction
Java introduction
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
 
Java notes
Java notesJava notes
Java notes
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Java-1st.pptx about Java technology before oops
Java-1st.pptx about Java technology before oopsJava-1st.pptx about Java technology before oops
Java-1st.pptx about Java technology before oops
 

Dernier

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 

Dernier (20)

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

JAVA OOP & Programming Guide

  • 1. Programming With JAVA OOP & JAVA Overview By: Sneha M M.Sc. (Software Technology)
  • 2. Overview  Introduction to OOP  Characteristics of OOP
  • 3. Introduction to OOP  OOP is an approach to program organization and development, which attempts to eliminate some of the pitfalls of programming methods.  It is by incorporating the best of structured programming features with several new concepts.
  • 4. Characteristics of OOP  Data Abstraction and Encapsulation  Inheritance  Polymorphism  Dynamic Binding  Message Communication
  • 5. Data Abstraction and Encapsulation  Encapsulation : The wrapping up of data and method in to a single units. (Data can be accessed by the methods which are inside the class)  Methods provide interface between objects data and the program.  Data Hiding : The insulation of the data from the direct access by the program.  Abstraction : Act of representing the essential features with out including the background details.
  • 6. Inheritance  Process by which object of one class acquires the properties of another class.  Hierarchical classification.  Reusability - adding additional features without modifying it. -deriving new class (sub class) from existing one. -new class will have combined features of both the classes.
  • 7. Polymorphism  Ability to take more than one form.  Ex: Operation of addition. - for 2 numbers as operands, the operation will generate a SUM. - for 2 strings as operands, the operation would produce a third string by concatenation.
  • 8. Dynamic Binding  Binding -Linking of procedure call to the code to be executed in response to the call.  Dynamic Binding – code associated with a given procedure call is not known until the time of the call at runtime.  Associated with polymorphism & inheritance.
  • 9. Message Communication.  The process of programming in OO Language involves 2 basic steps : 1. Creating Classes – define objects and their behaviour. 2. Creating Objects from class definitions. 3. Establishing communication among objects. Ex: Employee.salary(name); Employee – object Salary – message Name – parameter that contains information.
  • 10. Benefits of OOP • Inheritance – Eliminate code and extend the use of existing class. • Data Hiding - Helps the programmer to build secure program. • Objects – Easy to partition program. • Object oriented system can be easily upgraded.
  • 11. Overview of JAVA Language.  Introduction  Writing JAVA Program  Implementing JAVA Program  JVM  JAVA Tokens  Command Line Arguments.
  • 12.  JAVA is a general purpose OOP language.  We can develop two types of JAVA programs : - Standalone applications -Web Applets  Executing a standalone JAVA Program involves 2 steps: 1. Compiling source code into byte code using javac compiler. 2. Executing byte code program using java interpreter.  Applets are small java programs developed for Internet applications Introduction
  • 13. Two ways of using JAVA Java Source Code Written in java to carry out certain task Located on server can be downloaded and executed Applets Type Application Type Java Enabled Web browser Java Interpreter Java Compiler Output Output
  • 14. Two ways of using JAVA Java Source Code Applets Type Application Type Java Enabled Web browser Java Interpreter Java Compiler Output Output
  • 15. Two ways of using JAVA Java Source Code Applets Type Application Type Java Enabled Web browser Java Interpreter Java Compiler Output Output
  • 16. Two ways of using JAVA Java Source Code Applets Type Application Type Java Enabled Web browser Java Interpreter Java Compiler Output Output
  • 17. Writing a JAVA Program
  • 19. Explanation..  Class Declaration – class P1 – declares class - object oriented construct.  Class is a keyword  P1 is a java identifier- specifies name of the class.  The main line – public static void main(String[] args)  main – method  Starting point for the interpreter to begin execution of the program.  A java application can have any no.of classes but only one of them must include a main method to initiate the execution.  Applet does not use the main method.
  • 20. public static void main(String[] args)  Public:  An access specifier that declares the main method as unprotected and therefore making it accessible to all other classes.  Static:  Declares the method as one that belongs to entire class and not a part of any objects of a class.  Since the interpreter uses main method before any objects are created, it must be always be declared as static.  Void:  Type modifier states that the main does not return any value.  All parameters to a method are declared inside a pair of parenthesis.  String[] args:  Declares a parameter named args, which contain an array of objects of the class type string.
  • 21. Java Program Structure Documentation Section •Comprises a set of comment lines. •/*..*/ known as documentation comment Package Statement • First statement allowed in java file. • Declares Package name and inform compiler that classes defined here belong to this package. Import Statements •Comes next to package statement but before any class declarations. •Import student.test – instructs the interpreter to load the test class contained the package student.So we can have access to classes that are the part of other named packages.
  • 22. Contd.. Interface Statements •It is like class but includes a group of method declarations which is optional section and is used only when we wish to implement multiple inheritance. •New concept in java. Class Definitions •A java program may contain multiple class definitions. •Classes are essential and primary elements of java program. •The number of classes used depends on the complexity of the problem. Main method class •The main method creates objects of different classes and establishes communication between them. •On reaching the end of the main, program terminates and control passes back to the OS.
  • 23. Implementing a JAVA Program  Creating the program  Compiling the program  Running the program
  • 24. Creating the program  The file is called sourcefile. It has extension .java.  If a program contain multiple classes, the file name must be the class name of the class containing the main method.
  • 25. Compiling the Program  To compile the program we must run the java compiler javac, with the name of the source file on the command line – javac P1.java  If there is no error it automatically creates a file called P1.class i.e., the byte code file containing the byte codes of the program- <classname>.class
  • 26. Running a Program  Here we need to use the java interpreter to run the standalone program.  At command prompt type Java P1 Machine Neutral Compiler converts source code files in to bytecode files which are machine independent and therefore can be run on any machine. Java interpreter reads the byte code files and translates them into machine code for specific machine on which java program is running.
  • 27. JAVA Virtual Machine  Java compiler produces an intermedia code known as byte code for machine that does not exist.  This machine is called JVM and it exists only inside the computer memory.  It is a simulated computer within the computer and does all the major functions of a real computer.
  • 28. Process of compilation Java Program Java Compiler Virtual Machine Source Code Byte Code Byte Code Java Interpreter Machine Code Virtual Machine Real Machine
  • 29. Process of compilation Java Program Java Compiler Virtual Machine Source Code Byte Code Byte Code Java Interpreter Machine Code Virtual Machine Real Machine
  • 30. Process of compilation Java Program Java Compiler Virtual Machine Source Code Byte Code Byte Code Java Interpreter Machine Code Virtual Machine Real Machine
  • 31. Process of compilation Java Program Java Compiler Virtual Machine Source Code Byte Code Byte Code Java Interpreter Machine Code Virtual Machine Real Machine
  • 32. Process of compilation Java Program Java Compiler Virtual Machine Source Code Byte Code Byte Code Java Interpreter Machine Code Virtual Machine Real Machine
  • 33. Process of compilation Java Program Java Compiler Virtual Machine Source Code Byte Code Byte Code Java Interpreter Machine Code Virtual Machine Real Machine
  • 34. JAVA Tokens  A java program is basically a collection of classes.  A class is defined by set of declaration statements and methods containing executable statements.  Smallest individual units in a program is known as tokens.  Java language includes 5 types of tokens :  Reserved Keywords  Identifiers  Literals  Operators  Separators
  • 35.  Programmer designed tokens.  They are used for – Naming 1. classes 2. Methods 3. Variables 4. Objects 5. Labels 6. Packages 7. Interfaces Identifiers
  • 36. Rules followed by Identifiers 1. They can have alphabets, digits, underscore and dollar sign characters. 2. They must not begin with a digit. 3. Uppercase and lowercase letters are distinct. 4. They can be of any length.
  • 37. Command Line Arguments  Parameters that are supplied to the application program at the time of invoking it for execution. Ex : java P1 BASIC FORTRAN C++ Java It consists four arguments. These are assigned to the array args as follows: args[0]->BASIC args[1]->FORTRAN args[2]->C++ args[3]->Java
  • 40. Use of Math Functions  import java.lang.Math; The purpose of this statement to instruct the interpreter to load the Math class from the package lang.  The examples discussed uses only one class that uses the main method.  A real life application will generally requires multiple classes.
  • 42. Classes & Objects  Underlying structure of all java programs is classes.  Classes create objects and objects use methods to communicate between them.  Classes provide convenient method for packing together a group of logically related data items and functions that work on them.  In java data items are called fields and the functions are called methods.
  • 43.  Class classname [ extends superclassname] { [variable declaration;] [method declaration;] } Defining a Class
  • 44. Adding Data Fields, Method to class and creating objects
  • 45. Constructors.  Constructors enables an object to initialize itself when it is created.  Constructors are methods of class having same name as that of class name and used to initialize instance variables of the class.  They do not specify any return type not even void due to they return instance of the class itself.
  • 47.  Creating methods that have same name but with different parameter lists and different definitions.  Ex: class Rectangl { int length, width; //CONSTRUCTOR Rooml(int x, int y) { length= x; width = y; } Rooml(int x, int y) { length=width= x; } int recArea() { int area = length*width; return(area); } Method Overloading

Notes de l'éditeur

  1. Sub class defines only those features that are unique to it.
  2. Objects send and receive messages for communication that leads to execution of procedure i.e., invoke a method.
  3. Package contains collection of classes.