SlideShare une entreprise Scribd logo
1  sur  49
Introduction to Java
 Java is one of the world's most important and widely used
computer languages, and it has held this distinction for
many years.
 Java is Object oriented programming language.
 Helps to create modular programs and reusable code.
 Java is free to access and can run on all platforms.
 Java was developed by James Gosling, Patrick Naughton,
Mike Sheridan at Sun Microsystems Inc. in 1991.
 The initial name was Oak but it was renamed to Java in
1995 as OAK was a registered trademark of another Tech
company.
Overview Of Java
 Java was initially launched as Java 1.0 but soon after its initial
release, Java 1.1 was launched. Java 1.1 redefined event
handling, new library elements were added.
 In Java 1.2 Swing and Collection framework was added
and suspend(), resume() and stop()methods were deprecated
from Thread class
 JAVA EDITIONS.
 J2SE(Java 2 Standard Edition) - to develop client-side
standalone applications or applets.
 J2ME(Java 2 Micro Edition ) - to develop applications for
mobile devices such as cell phones.
 J2EE(Java 2 Enterprise Edition ) - to develop server-side
applications such as Java servlets and Java ServerPages.
Evolution Of Java
.
 Java is widely used in every corner of world and of human life
 Java is not only used in softwares but is also widely used in
designing hardware controlling software components.
 Banking: To deal with transaction management.
 Retail: Billing applications that you see in a store/restaurant are
completely written in Java.
 Information Technology: Java is designed to solve
implementation dependencies.
 Android: Applications are either written in Java or use Java API.
Financial services: It is used in server-side applications.
 Stock market: To write algorithms as to which company they
should invest in.
 Big Data: Hadoop MapReduce framework is written using Java.
 Scientific and Research Community.
Application of Java
 Developing Desktop Applications
 Web Applications like Linkedin.com,
Snapdeal.com etc
 Mobile Operating System like Android
 Embedded Systems
 Robotics and games etc.
Cont..
Features Of Java
 Java is easy to learn and its syntax is quite simple, clean and
easy to understand.
 The confusing and ambiguous concepts of C++ are either left
out in Java or they have been re-implemented in a cleaner
way.
 It is an evolving language
 Does not have complex features as other programming
languages like
 Operator overloading,
 Multiple inheritance through classes, pointers and
 Explicit memory allocation.
Simple
 In java everything is Object which has some
state and behaviour.
 Java can be easily extended as it is based on
Object Model.
 Object oriented programming is a
methododoly in which programs are
organized as collection of objects, each of
which represents an instance of a class
Object Oriented
 Two main problems which cause program failures
i.e memory management mistakes and
mishandled runtime errors can be overcome.
 Memory management mistakes can be overcome by
garbage collection. Garbage collection is automatic de-
allocation of objects which are no longer needed.
 Mishandled runtime errors are resolved by Exception
Handling procedures.
 Java eliminates error prone codes by checking the code at
compile time and runtime .
Robust
Portable
 Unlike other programming languages such as
C, C++ etc which are compiled into platform
specific machines.
 Java is write-once, run-anywhere language-
compiled version of class can run on any
platform.
Platform Independent
 When it comes to security, Java is always the first choice.
With java secure features it enable us to develop virus
free, temper free system.
 Java program always runs in Java virtual machine
environment with almost null interaction with system OS,
hence it is more secure.
 Provides a virtual firewall between the application and
the computer.
 Java codes are confined within Java Runtime
Environment (JRE).
 No use of explicit pointers.
Secure
 Java multithreading feature makes it possible to
write program that can do many tasks
simultaneously. Benefit of multithreading is
that it utilizes same memory and other
resources to execute multiple threads at the
same time, like While typing, grammatical
errors are checked along.
Multi Threading
 Compiler generates bytecodes, which have
nothing to do with a particular computer
architecture, hence a Java program is easy to
intrepret on any machine.
 Once compiled Java class file can run on any
platform
Architectural Neutral
JAVA COMPILER
JAVA BYTE CODE
JAVA INTERPRETER
Macintosh Solaris Windows Vista
(translator)
(same for all platforms)
(one for each different system)
Windows 7
 Java Byte code can be carried to any platform.
No implementation dependent features.
 Everything related to storage is predefined,
example: size of primitive data types
 Byte codes are interpeted by JVM
Portable
 Java is an interpreted language, so it will never
be as fast as a compiled language like C or C++.
But, Java enables high performance with the
use of just-in-time compiler.
High Performance
 C is a structured language and Java is an object
oriented language and has mechanism to define
classes and objects.
 Java does not support an explicit pointer type
 Java does not have preprocessor, so we cant use
#define, #include and #ifdef statements.
 Java does not include structures, unions and enum
data types.
 Java does not include keywords like goto, sizeof and
typedef.
 Java adds labeled break and continue statements.
C Language and Java Compared
 Java does not support operator over loading.
 Java does not perform automatic type conversions that
result in loss of precision.
 Java does not support global variables. Every method and
variable is declared within a class and forms part of that
class.
 Java does not allow default arguments.
 Java does not support inheritance of multiple super classes
by a sub class (i.e., multiple inheritance). This is
accomplished by using “interface” concept.
 It is not possible to declare unsigned integers in java.
 In java objects are passed by reference only. In C++ objects
may be passed by value or reference.
C++ and Java Compared
 Multithreading, that allows two or more pieces of the same
program to execute concurrently.
 C++ has a set of library functions that use a common header file.
But java replaces it with its own set of API classes.
 It adds packages and interfaces.
 Java supports automatic garbage collection.
 break and continue statements have been enhanced in java to
accept labels as targets.
 The use of unicode characters ensures portability.
NEW FEATURES ADDED IN
JAVA
Java Runtime Environment
 JRE : The Java Runtime Environment (JRE) provides the
libraries, the Java Virtual Machine, and other components
to run applets and applications written in the Java
programming language.
 JRE does not contain tools and utilities such as compilers
or debuggers for developing applets and applications.
 JRM=JVM+ set of libraries+ other additional fies
JRE
Java Development Kit
 JDK : The JDK also called Java Development
Kit is a superset of the JRE, and contains
everything that is in the JRE, plus tools such as
the compilers and debuggers necessary for
developing applets and applications.
 JDK=JRE+ Development tools
JDK
 Java virtual Machine(JVM) is a virtual Machine that provides
runtime environment to execute java byte code.
 The JVM doesn't understand Java pogram, that's why you
compile your *.java files to obtain *.class files that contain the
bytecodes understandable by the JVM.
 JVM control execution of every Java program. It enables features
such as automated exception handling, Garbage-collected heap.
What is JVM?
JVM Architecture
 Class Loader : Class loader loads the Class for execution.
 Method area : Stores pre-class structure as constant pool.
 Heap : Heap is in which objects are allocated.
 Stack : Local variables and partial results are store here. Each
thread has a private JVM stack created when the thread is
created.
 Program register : Program register holds the address of JVM
instruction currently being executed.
Conti..
 Native method stack : It contains all native used in
application.
 Executive Engine : Execution engine controls the
execute of instructions contained in the methods of
the classes.
 Native Method Interface : Native method interface
gives an interface between java code and native code
during execution.
 Native Method Libraries : Native Libraries consist
of files required for the execution of native code.
Conti..
 Object
 Class
 Inheritance
 Polymorphism
 Abstraction
 Encapulation
Object Oriented Concepts
 Abstraction
 Denotes the extraction of essential characteristics of an object that distinguish from all
other kinds of objects.
 Encapsulation
 Hiding the implementation details of a class.
 Forces the user to use an interface to access the data.
 Inheritance
 Process by which one class acquires the properties and functionalities of the other.
 Polymorphism
 Means the ability of methods to exist in several different forms
Object Oriented Programming
Object
31
 Objects are the basic run time entities in an object oriented system.
They may represent a person, a place, a bank account, a table of
data or any item that the program has to handle.
 Objects have two characteristics: They have states and behaviors.
 Object: Car
State: Color, Brand, Model
Behavior: Accelerate, Slow Down, Gear change.
What is the state and behavior of this bulb?
A bulb:
1. It’s a real-world thing.
2. Can be switched on to generate light and switched off.
3. It has real features like the glass covering, filament and holder.
4. It also has conceptual features like power.
5. A bulb manufacturing factory produces many bulbs based on a basic
description / pattern of what a bulb is.
object
methods
member variables
class
Putting it together
32
Class
33
 A class is a construct created in object-oriented programming
languages that enables creation of objects.
 Also sometimes called blueprint or template or prototype
from which objects are created.
 It defines members (variables and methods).
 Characteristics of an object are represented in a class as
Properties/state/variables. The actions that can be performed
by objects become functions of the class and is referred to as
Methods/behaviour.
 A class is an abstraction.
class <ClassName>
{
attributes/variables;
Constructors();
methods();
}
Class syntax
Abstraction
35
 Abstraction refers to the act of representing essential features
without including the background details or explanations.
 Example
 For a Doctor you are a Patient
 Name, Age, Old medical records
 For a Teacher you are a Student
 Name, Roll Number/RegNo, Education background
 For HR Staff you are ______________
 ___________,_____________,___________
Abstraction denotes essential characteristics of an object that
distinguish it from all other kinds of objects and thus provide crisply
defined conceptual boundaries, relative to the perspective of the
viewer.
-Grady Booch
Encapsulation
36
 Encapsulation is binding data and operations that work on data
together in a construct.
 Encapsulation involves Data and Implementation Hiding.
Would you like it if your CPU is given
to you like this?
What are the problems if it were given
to you like this?
Encapsulation is the process of compartmentalizing the elements of
abstraction that constitute its structure and behavior; encapsulation
serves to separate the contractual interface of an abstraction and its
implementation.
- Grady Booch
Class and Encapsulation
Student
•-roll: long
• -name: String
• + display(): void
• + read(): boolean
Rectangle
• -length: int
• -width:int
• +area(): int
LinkedList
•-Node
•+ addFirst(Node n)
•+ remove(Node n)
•+ add(Node n, int pos)
- : private
+ : public
Reuse in Object Oriented
Programming
38
 Object Oriented programming also implements reuse in the same
way that we do in real life.
 Using
 has-a
 is-a
 Has-a or composition relationship is implemented by having a
class having another class as its member, or rather an object
having another object as its member.
 Car has a Stereo
 College has Teachers and Students
 Is-a is implemented through what we call inheritance relationship
Inheritance
 Inheritance allows to reuse classes by deriving a new class from
an existing one
 The existing class is called the parent class, or superclass, or base
class
 The derived class is called the child class or subclass. The child
class inherits characteristics of the parent class(i.e the child class
inherits the methods and data defined for the parent class
 Defines IS-A relationship between classes
 Cat IS-A Animal
 Car IS-A Vehicle
 Rose IS-A Flower
Inheritance hierarchy
40
Animal
legs
tail
run()
Dog
bark()
Tiger
growl()
CatFamily
paddedClaws
whiskers
Cat
meow()
Single -level
Multi-level
 Many Object-orientated language does not support this type of
inheritance.
 Java, C# are the examples of object-oriented language that does
not support multiple inheritance through classes.
Mammal Bird
Bat
Multiple inheritance
{ {Super class Subclass
42
 Fruit
 Library
 Cat
 Bird
 Parrot
 Music
 Tiger
 Books
 Apple
 Mango
Activity
 Given the following classes. Can you form inheritance hierarchy?
 Person
 Teacher
 Student
 HOD
 Typist
 Clerk
 What are the common members shared ?
Polymorphism
A concept in type theory, according to which a name (such as a
variable declaration) may denote objects of many different classes
that are related by some common superclass; thus, any object
denoted by this name is able to respond to some common set of
operations in different ways.
- Grady Booch
Polymorphism example
Flower
fragrance()
Rose
fragrance()
Sunflower
fragrance()
FlowerVase
Flower f[]
smell()
 You pick a rose from the vase and smell it?
 What fragrance do you expect?
Flower
fragrance()
Rose
fragrance()
Sunflower
fragrance()
FlowerVase
Flower f[]
smell()
f[0]= rose;
f[1]= sunflower;
….
f[0]. fragrance();
f[1]. fragrance();
…
Benefits of OOP
1. Emphasis is on data rather than procedure.
2. Programs are divided into objects.
3. Methods are reused.
4. Methods that operate on the data of an object are tied together in the data
structure.
5. Data is hidden and can not be accessed by external functions.
6. Objects may communicate with each other through .
7. Good control over data, data of an object can be accessed by methods
associated with the object.
8. Easy to test, upgrade and debug.
 Client-Server Systems(OCSI)
 Object-Oriented Databases(ODBMS)
 Real-Time System Design
 Office Automation Systems
 CAD/CAM Systems
Applications of OOPs
 Object-oriented programming is a method of implementation in which
programs are organized as cooperative collections of objects.
 The object’s state is determined by the value of its properties and its
behavior is determined by the operations that it provides.
 Abstraction is the process of taking only a set of essential characteristics
from something.
 Encapsulation is binding data and operations that work on data together
in a construct.
 Inheritance defines relationship among classes, wherein one class share
structure or behavior defined in one or more classes.
 Polymorphism is using a function in many forms. Poly means ‘many’,
Morphism means ‘forms’.
Summary

Contenu connexe

Tendances

Multithreading in-java
Multithreading in-javaMultithreading in-java
Multithreading in-javaaalipalh
 
Java Course 10: Threads and Concurrency
Java Course 10: Threads and ConcurrencyJava Course 10: Threads and Concurrency
Java Course 10: Threads and ConcurrencyAnton Keks
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and ConcurrencyRajesh Ananda Kumar
 
L22 multi-threading-introduction
L22 multi-threading-introductionL22 multi-threading-introduction
L22 multi-threading-introductionteach4uin
 
Lecture - 1 introduction to java
Lecture - 1 introduction to javaLecture - 1 introduction to java
Lecture - 1 introduction to javamanish kumar
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaMonika Mishra
 
Thread model of java
Thread model of javaThread model of java
Thread model of javamyrajendra
 
12 multi-threading
12 multi-threading12 multi-threading
12 multi-threadingAPU
 
Java Multithreading Using Executors Framework
Java Multithreading Using Executors FrameworkJava Multithreading Using Executors Framework
Java Multithreading Using Executors FrameworkArun Mehra
 
Basic of Multithreading in JAva
Basic of Multithreading in JAvaBasic of Multithreading in JAva
Basic of Multithreading in JAvasuraj pandey
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to javaKalai Selvi
 

Tendances (20)

Multithreading in-java
Multithreading in-javaMultithreading in-java
Multithreading in-java
 
Multithreading Concepts
Multithreading ConceptsMultithreading Concepts
Multithreading Concepts
 
Java Course 10: Threads and Concurrency
Java Course 10: Threads and ConcurrencyJava Course 10: Threads and Concurrency
Java Course 10: Threads and Concurrency
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and Concurrency
 
Basics of Java
Basics of JavaBasics of Java
Basics of Java
 
L22 multi-threading-introduction
L22 multi-threading-introductionL22 multi-threading-introduction
L22 multi-threading-introduction
 
Java Reflection
Java ReflectionJava Reflection
Java Reflection
 
Lecture - 1 introduction to java
Lecture - 1 introduction to javaLecture - 1 introduction to java
Lecture - 1 introduction to java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Thread model of java
Thread model of javaThread model of java
Thread model of java
 
12 multi-threading
12 multi-threading12 multi-threading
12 multi-threading
 
Java Multithreading Using Executors Framework
Java Multithreading Using Executors FrameworkJava Multithreading Using Executors Framework
Java Multithreading Using Executors Framework
 
Basic of Multithreading in JAva
Basic of Multithreading in JAvaBasic of Multithreading in JAva
Basic of Multithreading in JAva
 
Core java
Core java Core java
Core java
 
Java basic
Java basicJava basic
Java basic
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
Multithreading in Java
Multithreading in JavaMultithreading in Java
Multithreading in Java
 
Threadnotes
ThreadnotesThreadnotes
Threadnotes
 

Similaire à Unit1 introduction to Java

JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxDrPreethiD1
 
java introduction.docx
java introduction.docxjava introduction.docx
java introduction.docxvikasbagra9887
 
JAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptxJAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptxSuganthiDPSGRKCW
 
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
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java SlidesVinit Vyas
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java LanguagePawanMM
 
Java Introduction
Java IntroductionJava Introduction
Java Introductionjaveed_mhd
 
Java Basics
Java BasicsJava Basics
Java BasicsKhan625
 
Java Basics in Mule
Java Basics in MuleJava Basics in Mule
Java Basics in MuleRajkattamuri
 
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
 
Introduction to java
Introduction to java Introduction to java
Introduction to java javeed_mhd
 

Similaire à Unit1 introduction to Java (20)

Java1
Java1Java1
Java1
 
Java
Java Java
Java
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptx
 
java introduction.docx
java introduction.docxjava introduction.docx
java introduction.docx
 
JAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptxJAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptx
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
 
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
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Java Basics in Mule
Java Basics in MuleJava Basics in Mule
Java Basics in Mule
 
Java in Mule
Java in MuleJava in Mule
Java in Mule
 
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
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 

Plus de DevaKumari Vijay

Unit 1 computer architecture (1)
Unit 1   computer architecture (1)Unit 1   computer architecture (1)
Unit 1 computer architecture (1)DevaKumari Vijay
 
Unit 2 monte carlo simulation
Unit 2 monte carlo simulationUnit 2 monte carlo simulation
Unit 2 monte carlo simulationDevaKumari Vijay
 
Decisiontree&amp;game theory
Decisiontree&amp;game theoryDecisiontree&amp;game theory
Decisiontree&amp;game theoryDevaKumari Vijay
 
Unit2 network optimization
Unit2 network optimizationUnit2 network optimization
Unit2 network optimizationDevaKumari Vijay
 
Unit 4 simulation and queing theory(m/m/1)
Unit 4  simulation and queing theory(m/m/1)Unit 4  simulation and queing theory(m/m/1)
Unit 4 simulation and queing theory(m/m/1)DevaKumari Vijay
 
Unit 1 introduction to simulation
Unit 1 introduction to simulationUnit 1 introduction to simulation
Unit 1 introduction to simulationDevaKumari Vijay
 
Unit2 montecarlosimulation
Unit2 montecarlosimulationUnit2 montecarlosimulation
Unit2 montecarlosimulationDevaKumari Vijay
 
Unit 4 exceptions and threads
Unit 4 exceptions and threadsUnit 4 exceptions and threads
Unit 4 exceptions and threadsDevaKumari Vijay
 
Unit3 part3-packages and interfaces
Unit3 part3-packages and interfacesUnit3 part3-packages and interfaces
Unit3 part3-packages and interfacesDevaKumari Vijay
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysDevaKumari Vijay
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithmDevaKumari Vijay
 

Plus de DevaKumari Vijay (20)

Unit 1 computer architecture (1)
Unit 1   computer architecture (1)Unit 1   computer architecture (1)
Unit 1 computer architecture (1)
 
Os ch1
Os ch1Os ch1
Os ch1
 
Unit2
Unit2Unit2
Unit2
 
Unit 1
Unit 1Unit 1
Unit 1
 
Unit 2 monte carlo simulation
Unit 2 monte carlo simulationUnit 2 monte carlo simulation
Unit 2 monte carlo simulation
 
Decisiontree&amp;game theory
Decisiontree&amp;game theoryDecisiontree&amp;game theory
Decisiontree&amp;game theory
 
Unit2 network optimization
Unit2 network optimizationUnit2 network optimization
Unit2 network optimization
 
Unit 4 simulation and queing theory(m/m/1)
Unit 4  simulation and queing theory(m/m/1)Unit 4  simulation and queing theory(m/m/1)
Unit 4 simulation and queing theory(m/m/1)
 
Unit4 systemdynamics
Unit4 systemdynamicsUnit4 systemdynamics
Unit4 systemdynamics
 
Unit 3 des
Unit 3 desUnit 3 des
Unit 3 des
 
Unit 1 introduction to simulation
Unit 1 introduction to simulationUnit 1 introduction to simulation
Unit 1 introduction to simulation
 
Unit2 montecarlosimulation
Unit2 montecarlosimulationUnit2 montecarlosimulation
Unit2 montecarlosimulation
 
Unit 3-Greedy Method
Unit 3-Greedy MethodUnit 3-Greedy Method
Unit 3-Greedy Method
 
Unit 5 java-awt (1)
Unit 5 java-awt (1)Unit 5 java-awt (1)
Unit 5 java-awt (1)
 
Unit 4 exceptions and threads
Unit 4 exceptions and threadsUnit 4 exceptions and threads
Unit 4 exceptions and threads
 
Unit3 part3-packages and interfaces
Unit3 part3-packages and interfacesUnit3 part3-packages and interfaces
Unit3 part3-packages and interfaces
 
Unit3 part2-inheritance
Unit3 part2-inheritanceUnit3 part2-inheritance
Unit3 part2-inheritance
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithm
 

Dernier

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Dernier (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Unit1 introduction to Java

  • 2.  Java is one of the world's most important and widely used computer languages, and it has held this distinction for many years.  Java is Object oriented programming language.  Helps to create modular programs and reusable code.  Java is free to access and can run on all platforms.  Java was developed by James Gosling, Patrick Naughton, Mike Sheridan at Sun Microsystems Inc. in 1991.  The initial name was Oak but it was renamed to Java in 1995 as OAK was a registered trademark of another Tech company. Overview Of Java
  • 3.  Java was initially launched as Java 1.0 but soon after its initial release, Java 1.1 was launched. Java 1.1 redefined event handling, new library elements were added.  In Java 1.2 Swing and Collection framework was added and suspend(), resume() and stop()methods were deprecated from Thread class  JAVA EDITIONS.  J2SE(Java 2 Standard Edition) - to develop client-side standalone applications or applets.  J2ME(Java 2 Micro Edition ) - to develop applications for mobile devices such as cell phones.  J2EE(Java 2 Enterprise Edition ) - to develop server-side applications such as Java servlets and Java ServerPages. Evolution Of Java
  • 4. .  Java is widely used in every corner of world and of human life  Java is not only used in softwares but is also widely used in designing hardware controlling software components.  Banking: To deal with transaction management.  Retail: Billing applications that you see in a store/restaurant are completely written in Java.  Information Technology: Java is designed to solve implementation dependencies.  Android: Applications are either written in Java or use Java API. Financial services: It is used in server-side applications.  Stock market: To write algorithms as to which company they should invest in.  Big Data: Hadoop MapReduce framework is written using Java.  Scientific and Research Community. Application of Java
  • 5.  Developing Desktop Applications  Web Applications like Linkedin.com, Snapdeal.com etc  Mobile Operating System like Android  Embedded Systems  Robotics and games etc. Cont..
  • 7.  Java is easy to learn and its syntax is quite simple, clean and easy to understand.  The confusing and ambiguous concepts of C++ are either left out in Java or they have been re-implemented in a cleaner way.  It is an evolving language  Does not have complex features as other programming languages like  Operator overloading,  Multiple inheritance through classes, pointers and  Explicit memory allocation. Simple
  • 8.  In java everything is Object which has some state and behaviour.  Java can be easily extended as it is based on Object Model.  Object oriented programming is a methododoly in which programs are organized as collection of objects, each of which represents an instance of a class Object Oriented
  • 9.  Two main problems which cause program failures i.e memory management mistakes and mishandled runtime errors can be overcome.  Memory management mistakes can be overcome by garbage collection. Garbage collection is automatic de- allocation of objects which are no longer needed.  Mishandled runtime errors are resolved by Exception Handling procedures.  Java eliminates error prone codes by checking the code at compile time and runtime . Robust
  • 10. Portable  Unlike other programming languages such as C, C++ etc which are compiled into platform specific machines.  Java is write-once, run-anywhere language- compiled version of class can run on any platform. Platform Independent
  • 11.  When it comes to security, Java is always the first choice. With java secure features it enable us to develop virus free, temper free system.  Java program always runs in Java virtual machine environment with almost null interaction with system OS, hence it is more secure.  Provides a virtual firewall between the application and the computer.  Java codes are confined within Java Runtime Environment (JRE).  No use of explicit pointers. Secure
  • 12.  Java multithreading feature makes it possible to write program that can do many tasks simultaneously. Benefit of multithreading is that it utilizes same memory and other resources to execute multiple threads at the same time, like While typing, grammatical errors are checked along. Multi Threading
  • 13.  Compiler generates bytecodes, which have nothing to do with a particular computer architecture, hence a Java program is easy to intrepret on any machine.  Once compiled Java class file can run on any platform Architectural Neutral
  • 14. JAVA COMPILER JAVA BYTE CODE JAVA INTERPRETER Macintosh Solaris Windows Vista (translator) (same for all platforms) (one for each different system) Windows 7
  • 15.  Java Byte code can be carried to any platform. No implementation dependent features.  Everything related to storage is predefined, example: size of primitive data types  Byte codes are interpeted by JVM Portable
  • 16.  Java is an interpreted language, so it will never be as fast as a compiled language like C or C++. But, Java enables high performance with the use of just-in-time compiler. High Performance
  • 17.  C is a structured language and Java is an object oriented language and has mechanism to define classes and objects.  Java does not support an explicit pointer type  Java does not have preprocessor, so we cant use #define, #include and #ifdef statements.  Java does not include structures, unions and enum data types.  Java does not include keywords like goto, sizeof and typedef.  Java adds labeled break and continue statements. C Language and Java Compared
  • 18.  Java does not support operator over loading.  Java does not perform automatic type conversions that result in loss of precision.  Java does not support global variables. Every method and variable is declared within a class and forms part of that class.  Java does not allow default arguments.  Java does not support inheritance of multiple super classes by a sub class (i.e., multiple inheritance). This is accomplished by using “interface” concept.  It is not possible to declare unsigned integers in java.  In java objects are passed by reference only. In C++ objects may be passed by value or reference. C++ and Java Compared
  • 19.  Multithreading, that allows two or more pieces of the same program to execute concurrently.  C++ has a set of library functions that use a common header file. But java replaces it with its own set of API classes.  It adds packages and interfaces.  Java supports automatic garbage collection.  break and continue statements have been enhanced in java to accept labels as targets.  The use of unicode characters ensures portability. NEW FEATURES ADDED IN JAVA
  • 20. Java Runtime Environment  JRE : The Java Runtime Environment (JRE) provides the libraries, the Java Virtual Machine, and other components to run applets and applications written in the Java programming language.  JRE does not contain tools and utilities such as compilers or debuggers for developing applets and applications.  JRM=JVM+ set of libraries+ other additional fies
  • 21. JRE
  • 22. Java Development Kit  JDK : The JDK also called Java Development Kit is a superset of the JRE, and contains everything that is in the JRE, plus tools such as the compilers and debuggers necessary for developing applets and applications.  JDK=JRE+ Development tools
  • 23. JDK
  • 24.  Java virtual Machine(JVM) is a virtual Machine that provides runtime environment to execute java byte code.  The JVM doesn't understand Java pogram, that's why you compile your *.java files to obtain *.class files that contain the bytecodes understandable by the JVM.  JVM control execution of every Java program. It enables features such as automated exception handling, Garbage-collected heap. What is JVM?
  • 26.  Class Loader : Class loader loads the Class for execution.  Method area : Stores pre-class structure as constant pool.  Heap : Heap is in which objects are allocated.  Stack : Local variables and partial results are store here. Each thread has a private JVM stack created when the thread is created.  Program register : Program register holds the address of JVM instruction currently being executed. Conti..
  • 27.  Native method stack : It contains all native used in application.  Executive Engine : Execution engine controls the execute of instructions contained in the methods of the classes.  Native Method Interface : Native method interface gives an interface between java code and native code during execution.  Native Method Libraries : Native Libraries consist of files required for the execution of native code. Conti..
  • 28.
  • 29.  Object  Class  Inheritance  Polymorphism  Abstraction  Encapulation Object Oriented Concepts
  • 30.  Abstraction  Denotes the extraction of essential characteristics of an object that distinguish from all other kinds of objects.  Encapsulation  Hiding the implementation details of a class.  Forces the user to use an interface to access the data.  Inheritance  Process by which one class acquires the properties and functionalities of the other.  Polymorphism  Means the ability of methods to exist in several different forms Object Oriented Programming
  • 31. Object 31  Objects are the basic run time entities in an object oriented system. They may represent a person, a place, a bank account, a table of data or any item that the program has to handle.  Objects have two characteristics: They have states and behaviors.  Object: Car State: Color, Brand, Model Behavior: Accelerate, Slow Down, Gear change. What is the state and behavior of this bulb?
  • 32. A bulb: 1. It’s a real-world thing. 2. Can be switched on to generate light and switched off. 3. It has real features like the glass covering, filament and holder. 4. It also has conceptual features like power. 5. A bulb manufacturing factory produces many bulbs based on a basic description / pattern of what a bulb is. object methods member variables class Putting it together 32
  • 33. Class 33  A class is a construct created in object-oriented programming languages that enables creation of objects.  Also sometimes called blueprint or template or prototype from which objects are created.  It defines members (variables and methods).  Characteristics of an object are represented in a class as Properties/state/variables. The actions that can be performed by objects become functions of the class and is referred to as Methods/behaviour.  A class is an abstraction.
  • 35. Abstraction 35  Abstraction refers to the act of representing essential features without including the background details or explanations.  Example  For a Doctor you are a Patient  Name, Age, Old medical records  For a Teacher you are a Student  Name, Roll Number/RegNo, Education background  For HR Staff you are ______________  ___________,_____________,___________ Abstraction denotes essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer. -Grady Booch
  • 36. Encapsulation 36  Encapsulation is binding data and operations that work on data together in a construct.  Encapsulation involves Data and Implementation Hiding. Would you like it if your CPU is given to you like this? What are the problems if it were given to you like this? Encapsulation is the process of compartmentalizing the elements of abstraction that constitute its structure and behavior; encapsulation serves to separate the contractual interface of an abstraction and its implementation. - Grady Booch
  • 37. Class and Encapsulation Student •-roll: long • -name: String • + display(): void • + read(): boolean Rectangle • -length: int • -width:int • +area(): int LinkedList •-Node •+ addFirst(Node n) •+ remove(Node n) •+ add(Node n, int pos) - : private + : public
  • 38. Reuse in Object Oriented Programming 38  Object Oriented programming also implements reuse in the same way that we do in real life.  Using  has-a  is-a  Has-a or composition relationship is implemented by having a class having another class as its member, or rather an object having another object as its member.  Car has a Stereo  College has Teachers and Students  Is-a is implemented through what we call inheritance relationship
  • 39. Inheritance  Inheritance allows to reuse classes by deriving a new class from an existing one  The existing class is called the parent class, or superclass, or base class  The derived class is called the child class or subclass. The child class inherits characteristics of the parent class(i.e the child class inherits the methods and data defined for the parent class  Defines IS-A relationship between classes  Cat IS-A Animal  Car IS-A Vehicle  Rose IS-A Flower
  • 41.  Many Object-orientated language does not support this type of inheritance.  Java, C# are the examples of object-oriented language that does not support multiple inheritance through classes. Mammal Bird Bat Multiple inheritance
  • 42. { {Super class Subclass 42  Fruit  Library  Cat  Bird  Parrot  Music  Tiger  Books  Apple  Mango
  • 43. Activity  Given the following classes. Can you form inheritance hierarchy?  Person  Teacher  Student  HOD  Typist  Clerk  What are the common members shared ?
  • 44. Polymorphism A concept in type theory, according to which a name (such as a variable declaration) may denote objects of many different classes that are related by some common superclass; thus, any object denoted by this name is able to respond to some common set of operations in different ways. - Grady Booch
  • 46.  You pick a rose from the vase and smell it?  What fragrance do you expect? Flower fragrance() Rose fragrance() Sunflower fragrance() FlowerVase Flower f[] smell() f[0]= rose; f[1]= sunflower; …. f[0]. fragrance(); f[1]. fragrance(); …
  • 47. Benefits of OOP 1. Emphasis is on data rather than procedure. 2. Programs are divided into objects. 3. Methods are reused. 4. Methods that operate on the data of an object are tied together in the data structure. 5. Data is hidden and can not be accessed by external functions. 6. Objects may communicate with each other through . 7. Good control over data, data of an object can be accessed by methods associated with the object. 8. Easy to test, upgrade and debug.
  • 48.  Client-Server Systems(OCSI)  Object-Oriented Databases(ODBMS)  Real-Time System Design  Office Automation Systems  CAD/CAM Systems Applications of OOPs
  • 49.  Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects.  The object’s state is determined by the value of its properties and its behavior is determined by the operations that it provides.  Abstraction is the process of taking only a set of essential characteristics from something.  Encapsulation is binding data and operations that work on data together in a construct.  Inheritance defines relationship among classes, wherein one class share structure or behavior defined in one or more classes.  Polymorphism is using a function in many forms. Poly means ‘many’, Morphism means ‘forms’. Summary