SlideShare a Scribd company logo
Advance Java Lab
1
By
Vishal Choudhary
Department of Computer Engineering, PCE
2
With the invention of internet and world
wide web there is need of a language that
should be platform independent.
On internet we don't know in advance at
what platform our code or program
/application will be executed as all over the
world there are heterogeneous systems.
JAVA was not made for Internet
programming. Java was developed for
Microcontroller for platform neutral
execution. so there is no need to rewrite the
code each time for every Microcontroller.
James Gosling and his team start working on
a portable ,platform independent language
that could be used to produce code that
would run on variety of CPU under different
environment.
This effort leads to creation of JAVA
In portable language we can compile the
code by using different compiler on different
operating system.
e.g. in C source code
 On DOS we can compile the source code by
Turbo Borland Compiler
 On Window we can compile using VC++
Compiler
 For UNIX we can use CC/GCC compiler
JAVA VIRTUAL MACHINE is the
solution for platform independent
compilation
Specification designed by SUN Microsystems
1. Instruction set
2. File format
3. Class loading and execution Mechanism etc.
JVM is specification of JRE
JRE is implementation of JVM
JRE can be called JVM but JVM cannot be called JRE.
Car is called a Vehicle but Vehicle is not called Car
 A software vendor who wants to develop JRE
needs JVM
Main component of JRE
1 Byte code verifier
2.Class Loader
3.Just in time Compiler
4.Class Library
5.Security Policies
6.Memory Management.
 It is the package of JRE and tools(javac ,javap ,jar
etc.)
(jar is compression and decompression format of sun micro
system)
1. Application programmer needs JDK
2. End user needs JRE
3. A software vendor who wants to develop JRE
needs JVM(specification and license from
SunMicrosystem now owned by Oracle).
4. Every vendor can develop their own compiler of
java with license from sun micro system
according to their need.
The key to solve the security and portability
problem is that the output of Java compiler is not
executable code rather than it is BYTECODE.
Byte Code is a highly optimized set of
instructions to be executed by JRE(some time
called JVM)
JVM was designed as an interpreter for byte code.
JVM may be different from platform to platform
but all understand the same byte code.
 In real world we think in the form of object. We
give preference to object than on work that object
perform.
e.g: Teacher, Carpenter
JAVA designer want to develop a language that
should solve the problems that have solution
similar real world problems.
If we want to study we looks for teacher.
If we want to make a table, chair or any furniture we
looks for carpenter
 Object is an Instance of class
 At particular moment how that class is
behaving is know as object
 Suppose Light is class
Either it is on ,off,dim,bright
Light is on
Light is off
Light is bright
Light is Dim
 it is the way of thinking in terms of object on
the basis of this thinking a programming
model created by sun micro system in known
as object oriented programming structure
 SUN MicroSystem is a microelectronics
company designing chips for microcontroller
used in washing machines ,digital set top
box,Remote control etc.
 What is difference between microcontroller
and microprocessor?
Java's main features are
 1. Platform independent.
 2. Security
 For each platform we have to write a new
code.
 If a company is making 100 microcontroller
per day then 100 times we have to write the
code. because language depends on the
properties of hardware(instruction set,
instruction format, type of register)
Main Feature of Java:
1. Simple
2. Secure(The JVM performs verification on bytecode before running it to prevent the program
from performing unsafe operations such as branching to incorrect locations)
3. Object-Oriented
4. Robust(Java is robust because it is highly supported language, meaning that
unlike C you cannot crash your computer with a bad program)
5. Multithreaded
6. Architectural Neutral
(binary code format" that's independent of hardware
architectures, operating system interfaces, and window
systems)
7. Interpreted.
8. High-performance
(Just in time compilation)
9. Distributed (development of application to run over network
always need distributed languages)
10. Dynamic (During the execution of a program, Java can
dynamically load class libraries )
 It is slow in comparison of C/C++.because it
is both compiled and interpreted language.
 Applet cannot access local data. Only
download the data from site where applet is
located.
 No use of pointer so we cannot do flexible
data structure design.
 Need different JVM for different platform.
 It is strictly types language (every variable
have type, every expression has type) so
there is no flexibility in programming.
JAVA C++
1 Java is completely object oriented
language
C++ is extension of C with object oriented
behavior
2 Java does not support multiple
inheritances. But it can be achieved
using interface if needed.
C++ support multiple inheritance
3 Java does not support global
variable
Global variable can be declared in C++
4 Java does not support pointer. C++ support pointers.
5 In Java there is no destructor. In C++ there is use of destructor
6 Java does not provide header file C++ has header file.
7 Java code run on Virtual machine
(JVM)
C++ code runs on actual machine
8 In java automatic memory
management and garbage collection
Memory management is done manually by
new/delete.
9 Write once run any where Write once compile anywhere
Class MyExample
{
public Static Void main(String arr[])
{
System.out.println(“this is my example”);
}
}
 The word Class means that a new class is defined.
 MyExample is an identifier(called class name)
 All members of class should be declared inside
curly braces {…………….}
 Execution always start from main method.
 The keyword public mean that member may be
accessed by code outside the class in which it is
declared.
 main() must be declared as public since it must be
called by the code outside of its class when the
program is started.
 Keyword static allow main() to be called without
having to instantiate a particular instance of class.
since main() is called by JVM before any object are
made.
 Keyword void tells the compiler that main()
does not return a value.
 Object of type String store character string in
this case arr is an command line argument
presents when program is executed.
 System is a predefined class that provides
access to the system and out is output
stream that is connected to console.
Execution Model of C and C++
1.Application file is read and format is checked.
2.If format is valid .its instruction is loaded.
3.Address of first Inst. Is loaded in PC
4.Process asked to start execution.
5.Address of Instruction fetched from PC one by one.
6.Instruction is fetched from memory and is executed.
2.Class file is read and its format is checked.
3,4.If format is valid, class loader is asked to load it.
5.Just in time compiler(JITC) is asked to execute the class.
6.Instruction of class is read one by one.
7.For each instruction security policy is checked and instruction is
executed only if it satisfy security policy.
 .
 Eclipse
Class Rectangle
{
int l,b
//attribute
public void display()
{
System.out.println(“Length=”+l);
System.out.println(“Breadth=”+b);
}
public int area()
{
Return l*b;
}
Public void setDimension(int x,int y)
{
I=x;
B=y;
}
}
Class RectangleTest
{
public static void main(String
arr[])
{
Rectangle r = new Rectangle();
r.setDimension(20,30)
{
System.out.println(“dimension of
rectangle are”);
r.display();
System.out.println(“area of
rectangle r is =”+r.area());
}}
 Classname refrencevariable = new classname();
 Reference variable is a implicit pointer which
is used to contain the reference of objects.
 In java reference variable are dynamically
created. Hence they don’t have name and are
referenced through their reference variables.
 In C++: there is static allocation of objects
 r
 Rectangle r ======== r
l
b
Java  lab  zero lecture
Java  lab  zero lecture

More Related Content

What's hot

Basic Java I
Basic Java IBasic Java I
Chapter 1. java programming language overview
Chapter 1. java programming language overviewChapter 1. java programming language overview
Chapter 1. java programming language overview
Jong Soon Bok
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
jayc8586
 
Java notes
Java notesJava notes
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 
Byte code jvm
Byte code jvmByte code jvm
Byte code jvm
myrajendra
 
JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program Examples
Prof Chethan Raj C
 
1 Introduction To Java Technology
1 Introduction To Java Technology 1 Introduction To Java Technology
1 Introduction To Java Technology
dM Technologies
 
Training on java niit (sahil gupta 9068557926)
Training on java niit (sahil gupta 9068557926)Training on java niit (sahil gupta 9068557926)
Training on java niit (sahil gupta 9068557926)
Sahil Gupta
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
CS Lesson: Introduction to the Java virtual Machine
CS Lesson: Introduction to the Java virtual MachineCS Lesson: Introduction to the Java virtual Machine
CS Lesson: Introduction to the Java virtual Machine
Katrin Becker
 
Core Java
Core JavaCore Java
Java architecture
Java architectureJava architecture
Java architecture
Rakesh Vadnala
 
What is-java
What is-javaWhat is-java
What is-java
Shahid Rasheed
 
Core java slides
Core java slidesCore java slides
Core java slides
Abhilash Nair
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Sandeep Rawat
 
Java introduction
Java introductionJava introduction
Java introduction
NAVEENA ESWARAN
 
Programming in Java
Programming in JavaProgramming in Java
Programming in Java
Abhilash Nair
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
poonguzhali1826
 

What's hot (19)

Basic Java I
Basic Java IBasic Java I
Basic Java I
 
Chapter 1. java programming language overview
Chapter 1. java programming language overviewChapter 1. java programming language overview
Chapter 1. java programming language overview
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java notes
Java notesJava notes
Java notes
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
Byte code jvm
Byte code jvmByte code jvm
Byte code jvm
 
JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program Examples
 
1 Introduction To Java Technology
1 Introduction To Java Technology 1 Introduction To Java Technology
1 Introduction To Java Technology
 
Training on java niit (sahil gupta 9068557926)
Training on java niit (sahil gupta 9068557926)Training on java niit (sahil gupta 9068557926)
Training on java niit (sahil gupta 9068557926)
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
CS Lesson: Introduction to the Java virtual Machine
CS Lesson: Introduction to the Java virtual MachineCS Lesson: Introduction to the Java virtual Machine
CS Lesson: Introduction to the Java virtual Machine
 
Core Java
Core JavaCore Java
Core Java
 
Java architecture
Java architectureJava architecture
Java architecture
 
What is-java
What is-javaWhat is-java
What is-java
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Java introduction
Java introductionJava introduction
Java introduction
 
Programming in Java
Programming in JavaProgramming in Java
Programming in Java
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 

Similar to Java lab zero lecture

Java lab lecture 1
Java  lab  lecture 1Java  lab  lecture 1
Java lab lecture 1
vishal choudhary
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
DeepanshuMidha5140
 
Java-Unit-I.ppt
Java-Unit-I.pptJava-Unit-I.ppt
Java-Unit-I.ppt
RameswarGprec
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
Satyam Pandey
 
OOP-Chap2.docx
OOP-Chap2.docxOOP-Chap2.docx
OOP-Chap2.docx
NaorinHalim
 
CORE JAVA
CORE JAVACORE JAVA
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
Qualys
 
Srgoc java
Srgoc javaSrgoc java
Srgoc java
Gaurav Singh
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
kumar467
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
Mukesh Tekwani
 
Java1
Java1Java1
Java
Java Java
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
Harry Potter
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
James Wong
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
Tony Nguyen
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Fraboni Ec
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Young Alista
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Luis Goldster
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
Hoang Nguyen
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
DevaKumari Vijay
 

Similar to Java lab zero lecture (20)

Java lab lecture 1
Java  lab  lecture 1Java  lab  lecture 1
Java lab lecture 1
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
 
Java-Unit-I.ppt
Java-Unit-I.pptJava-Unit-I.ppt
Java-Unit-I.ppt
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
 
OOP-Chap2.docx
OOP-Chap2.docxOOP-Chap2.docx
OOP-Chap2.docx
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
 
Srgoc java
Srgoc javaSrgoc java
Srgoc java
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
 
Java1
Java1Java1
Java1
 
Java
Java Java
Java
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 

More from vishal choudhary

SE-Lecture1.ppt
SE-Lecture1.pptSE-Lecture1.ppt
SE-Lecture1.ppt
vishal choudhary
 
SE-Testing.ppt
SE-Testing.pptSE-Testing.ppt
SE-Testing.ppt
vishal choudhary
 
SE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.pptSE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.ppt
vishal choudhary
 
SE-Lecture-7.pptx
SE-Lecture-7.pptxSE-Lecture-7.pptx
SE-Lecture-7.pptx
vishal choudhary
 
Se-Lecture-6.ppt
Se-Lecture-6.pptSe-Lecture-6.ppt
Se-Lecture-6.ppt
vishal choudhary
 
SE-Lecture-5.pptx
SE-Lecture-5.pptxSE-Lecture-5.pptx
SE-Lecture-5.pptx
vishal choudhary
 
XML.pptx
XML.pptxXML.pptx
SE-Lecture-8.pptx
SE-Lecture-8.pptxSE-Lecture-8.pptx
SE-Lecture-8.pptx
vishal choudhary
 
SE-coupling and cohesion.ppt
SE-coupling and cohesion.pptSE-coupling and cohesion.ppt
SE-coupling and cohesion.ppt
vishal choudhary
 
SE-Lecture-2.pptx
SE-Lecture-2.pptxSE-Lecture-2.pptx
SE-Lecture-2.pptx
vishal choudhary
 
SE-software design.ppt
SE-software design.pptSE-software design.ppt
SE-software design.ppt
vishal choudhary
 
SE1.ppt
SE1.pptSE1.ppt
SE-Lecture-4.pptx
SE-Lecture-4.pptxSE-Lecture-4.pptx
SE-Lecture-4.pptx
vishal choudhary
 
SE-Lecture=3.pptx
SE-Lecture=3.pptxSE-Lecture=3.pptx
SE-Lecture=3.pptx
vishal choudhary
 
Multimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptxMultimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptx
vishal choudhary
 
MultimediaLecture5.pptx
MultimediaLecture5.pptxMultimediaLecture5.pptx
MultimediaLecture5.pptx
vishal choudhary
 
Multimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptxMultimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptx
vishal choudhary
 
MultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptxMultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptx
vishal choudhary
 
Multimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptxMultimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptx
vishal choudhary
 
Multimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptxMultimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptx
vishal choudhary
 

More from vishal choudhary (20)

SE-Lecture1.ppt
SE-Lecture1.pptSE-Lecture1.ppt
SE-Lecture1.ppt
 
SE-Testing.ppt
SE-Testing.pptSE-Testing.ppt
SE-Testing.ppt
 
SE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.pptSE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.ppt
 
SE-Lecture-7.pptx
SE-Lecture-7.pptxSE-Lecture-7.pptx
SE-Lecture-7.pptx
 
Se-Lecture-6.ppt
Se-Lecture-6.pptSe-Lecture-6.ppt
Se-Lecture-6.ppt
 
SE-Lecture-5.pptx
SE-Lecture-5.pptxSE-Lecture-5.pptx
SE-Lecture-5.pptx
 
XML.pptx
XML.pptxXML.pptx
XML.pptx
 
SE-Lecture-8.pptx
SE-Lecture-8.pptxSE-Lecture-8.pptx
SE-Lecture-8.pptx
 
SE-coupling and cohesion.ppt
SE-coupling and cohesion.pptSE-coupling and cohesion.ppt
SE-coupling and cohesion.ppt
 
SE-Lecture-2.pptx
SE-Lecture-2.pptxSE-Lecture-2.pptx
SE-Lecture-2.pptx
 
SE-software design.ppt
SE-software design.pptSE-software design.ppt
SE-software design.ppt
 
SE1.ppt
SE1.pptSE1.ppt
SE1.ppt
 
SE-Lecture-4.pptx
SE-Lecture-4.pptxSE-Lecture-4.pptx
SE-Lecture-4.pptx
 
SE-Lecture=3.pptx
SE-Lecture=3.pptxSE-Lecture=3.pptx
SE-Lecture=3.pptx
 
Multimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptxMultimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptx
 
MultimediaLecture5.pptx
MultimediaLecture5.pptxMultimediaLecture5.pptx
MultimediaLecture5.pptx
 
Multimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptxMultimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptx
 
MultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptxMultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptx
 
Multimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptxMultimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptx
 
Multimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptxMultimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptx
 

Recently uploaded

Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 

Recently uploaded (20)

Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 

Java lab zero lecture

  • 1. Advance Java Lab 1 By Vishal Choudhary Department of Computer Engineering, PCE
  • 2. 2
  • 3.
  • 4. With the invention of internet and world wide web there is need of a language that should be platform independent. On internet we don't know in advance at what platform our code or program /application will be executed as all over the world there are heterogeneous systems.
  • 5. JAVA was not made for Internet programming. Java was developed for Microcontroller for platform neutral execution. so there is no need to rewrite the code each time for every Microcontroller.
  • 6. James Gosling and his team start working on a portable ,platform independent language that could be used to produce code that would run on variety of CPU under different environment. This effort leads to creation of JAVA
  • 7. In portable language we can compile the code by using different compiler on different operating system. e.g. in C source code  On DOS we can compile the source code by Turbo Borland Compiler  On Window we can compile using VC++ Compiler  For UNIX we can use CC/GCC compiler
  • 8. JAVA VIRTUAL MACHINE is the solution for platform independent compilation
  • 9. Specification designed by SUN Microsystems 1. Instruction set 2. File format 3. Class loading and execution Mechanism etc. JVM is specification of JRE JRE is implementation of JVM JRE can be called JVM but JVM cannot be called JRE. Car is called a Vehicle but Vehicle is not called Car
  • 10.  A software vendor who wants to develop JRE needs JVM Main component of JRE 1 Byte code verifier 2.Class Loader 3.Just in time Compiler 4.Class Library 5.Security Policies 6.Memory Management.
  • 11.  It is the package of JRE and tools(javac ,javap ,jar etc.) (jar is compression and decompression format of sun micro system) 1. Application programmer needs JDK 2. End user needs JRE 3. A software vendor who wants to develop JRE needs JVM(specification and license from SunMicrosystem now owned by Oracle). 4. Every vendor can develop their own compiler of java with license from sun micro system according to their need.
  • 12. The key to solve the security and portability problem is that the output of Java compiler is not executable code rather than it is BYTECODE. Byte Code is a highly optimized set of instructions to be executed by JRE(some time called JVM) JVM was designed as an interpreter for byte code. JVM may be different from platform to platform but all understand the same byte code.
  • 13.  In real world we think in the form of object. We give preference to object than on work that object perform. e.g: Teacher, Carpenter JAVA designer want to develop a language that should solve the problems that have solution similar real world problems. If we want to study we looks for teacher. If we want to make a table, chair or any furniture we looks for carpenter
  • 14.  Object is an Instance of class  At particular moment how that class is behaving is know as object  Suppose Light is class Either it is on ,off,dim,bright Light is on Light is off Light is bright Light is Dim
  • 15.
  • 16.
  • 17.  it is the way of thinking in terms of object on the basis of this thinking a programming model created by sun micro system in known as object oriented programming structure  SUN MicroSystem is a microelectronics company designing chips for microcontroller used in washing machines ,digital set top box,Remote control etc.  What is difference between microcontroller and microprocessor?
  • 18. Java's main features are  1. Platform independent.  2. Security
  • 19.  For each platform we have to write a new code.  If a company is making 100 microcontroller per day then 100 times we have to write the code. because language depends on the properties of hardware(instruction set, instruction format, type of register)
  • 20. Main Feature of Java: 1. Simple 2. Secure(The JVM performs verification on bytecode before running it to prevent the program from performing unsafe operations such as branching to incorrect locations) 3. Object-Oriented 4. Robust(Java is robust because it is highly supported language, meaning that unlike C you cannot crash your computer with a bad program) 5. Multithreaded 6. Architectural Neutral (binary code format" that's independent of hardware architectures, operating system interfaces, and window systems) 7. Interpreted. 8. High-performance (Just in time compilation) 9. Distributed (development of application to run over network always need distributed languages) 10. Dynamic (During the execution of a program, Java can dynamically load class libraries )
  • 21.  It is slow in comparison of C/C++.because it is both compiled and interpreted language.  Applet cannot access local data. Only download the data from site where applet is located.  No use of pointer so we cannot do flexible data structure design.  Need different JVM for different platform.  It is strictly types language (every variable have type, every expression has type) so there is no flexibility in programming.
  • 22. JAVA C++ 1 Java is completely object oriented language C++ is extension of C with object oriented behavior 2 Java does not support multiple inheritances. But it can be achieved using interface if needed. C++ support multiple inheritance 3 Java does not support global variable Global variable can be declared in C++ 4 Java does not support pointer. C++ support pointers. 5 In Java there is no destructor. In C++ there is use of destructor 6 Java does not provide header file C++ has header file. 7 Java code run on Virtual machine (JVM) C++ code runs on actual machine 8 In java automatic memory management and garbage collection Memory management is done manually by new/delete. 9 Write once run any where Write once compile anywhere
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30. Class MyExample { public Static Void main(String arr[]) { System.out.println(“this is my example”); } }
  • 31.  The word Class means that a new class is defined.  MyExample is an identifier(called class name)  All members of class should be declared inside curly braces {…………….}  Execution always start from main method.  The keyword public mean that member may be accessed by code outside the class in which it is declared.  main() must be declared as public since it must be called by the code outside of its class when the program is started.  Keyword static allow main() to be called without having to instantiate a particular instance of class. since main() is called by JVM before any object are made.
  • 32.  Keyword void tells the compiler that main() does not return a value.  Object of type String store character string in this case arr is an command line argument presents when program is executed.  System is a predefined class that provides access to the system and out is output stream that is connected to console.
  • 33. Execution Model of C and C++ 1.Application file is read and format is checked. 2.If format is valid .its instruction is loaded. 3.Address of first Inst. Is loaded in PC 4.Process asked to start execution. 5.Address of Instruction fetched from PC one by one. 6.Instruction is fetched from memory and is executed.
  • 34. 2.Class file is read and its format is checked. 3,4.If format is valid, class loader is asked to load it. 5.Just in time compiler(JITC) is asked to execute the class. 6.Instruction of class is read one by one. 7.For each instruction security policy is checked and instruction is executed only if it satisfy security policy.
  • 36. Class Rectangle { int l,b //attribute public void display() { System.out.println(“Length=”+l); System.out.println(“Breadth=”+b); } public int area() { Return l*b; } Public void setDimension(int x,int y) { I=x; B=y; } } Class RectangleTest { public static void main(String arr[]) { Rectangle r = new Rectangle(); r.setDimension(20,30) { System.out.println(“dimension of rectangle are”); r.display(); System.out.println(“area of rectangle r is =”+r.area()); }}
  • 37.  Classname refrencevariable = new classname();  Reference variable is a implicit pointer which is used to contain the reference of objects.  In java reference variable are dynamically created. Hence they don’t have name and are referenced through their reference variables.  In C++: there is static allocation of objects  r  Rectangle r ======== r l b