SlideShare a Scribd company logo
1 of 6
Download to read offline
1. THE JAVA PROGRAMMING LANGUAGE
What is Java?
Java programming language is a high-level language that can be characterized by all of the
following buzzwords:
• Compiled and Interpreted

• Architecture neutral

• Distributed

• Object oriented

• Robust

• Secure

• Multithreaded

• Dynamic

• Extensible

• High performance

• Easy to learn

Java features elaborated:
1. Compiled and Interpreted
Usually a computer language is either compiled or interpreted. Java combines both these
features and thus there are two stages involved in a Java program. First, Java translates
the source code into bytecode instructions. Bytecodes are not machine instructions. So in
the next stage, the Java interpreter generates the machine code that can be directly
executed by the machine that is running the Java program. This interpretation is done by
the Java virtual machine.
2. Platform-independent and portable
Java programs can be easily moved from one computer system to another. If there are any
changes in the OS, processor, and other system resources, there is no need to change the
Java program. This portability is achieved in two ways: first Java generates the bytecode
instructions that can be run on any machine. Also, the size of the primitive data types are
machine independent. This portability is the reason behind the huge success of Java in the
networking domain, especially the Internet. We can download an applet from a remote
computer to our computer system and execute it locally.
3. Distributed
Java was designed with networking in mind. Java programs can share data across
networks. Java programs can open and access objects on network devices.
4. Object-oriented
Java is object oriented. No coding is permitted outside class definitions. An extensive
class library can be used by the programmer
5. Robust
Java is a robust language. All local variables must be initialized. There is strong typechecking. That is, all data must be declared explicitly. It has garbage-collection features
which means that memory management is no longer something the programmer needs to
Java - Chapter 1

Page 1 of 6
The Java Programming Language

be worried about. Java also does exception handling – serious errors are captured and the
risk of crashing the system is minimized.
6. Secure
Since Java has been designed for networked environments, security is an important
feature of this language. Java systems verify all memory accesses. The absence of
pointers in Java ensures that programs do not have access to all memory locations.
7. Multithreaded
Multithreading means handling many (multiple) tasks simultaneously. Java handles
multithreaded programs. It means that we need not wait for one task to be completed
before starting the next task. Such systems are very useful for graphical interactive
environments.
8. Dynamic and extensible
The linking of data and methods to where they are located, is done at run-time. New
classes can be loaded while a program is running. Linking is done on the fly. Even if
libraries are recompiled, there is no need to recompile code that uses classes in those
libraries. This differs from C++, which uses static binding.
By extensible we mean that Java programs can support functions written in other
languages such as C or C++. These functions are called native methods. Such functions
are linked dynamically at runtime.
9. High performance
Even though Java is interpreted (in the second stage), its speed is impressive compared to
other interpreted languages. This is due to the use of the intermediate bytecode. Also, the
multithreading feature further increases the speed of execution of Java programs.
10. Simple to learn
Java is a simple and small language. Many features of C / C++ have been removed from
Java. For example, pointers, preprocessor header files (e.g., #include <stdio.h>), goto
statement, operator overloading, multiple inheritance, etc have been eliminated from Java.

Differences between Java and C:
Although Java syntax is in many ways including operators and statements, there are many
significant differences in these languages.
No preprocessor
Java does not include a preprocessor(C and C++ both have the #include
preprocessor directive). Also #define, #ifdef are missing from Java.
No macro definitions
Java does not support macros (#define in C).
Page 2 of 6

Java - Chapter 1
The Java Programming Language

No global variables
There are no global variables in Java. Packages contain classes, classes contain fields
and methods, and methods contain local variables.
Well-defined primitive data types
All primitive data types in Java have well-defined sizes. In C, the size of short,
int, and long data types is platform-dependent. This hampers portability.
No pointers
Java does not support the concept of pointers. There is no address-of operator like &,
dereference operator like * or −>, or sizeof operator. Pointers are a source of bugs.
No goto statement
Java doesn't support a goto statement. Use of goto is regarded as poor
programming practice. Java adds labeled break and continue statements to the
flow-control statements offered by C. These are a good substitute for goto.
Garbage collection
The Java Virtual Machine performs garbage collection so that Java programmers do
not have to explicitly manage the memory used by all objects and arrays. This feature
eliminates another entire category of common bugs. It also eliminates memory leaks
from Java programs.
Variable declarations anywhere
C requires local variable declarations to be made at the beginning of a method or
block, while Java allows them anywhere in a method or block.
Forward Reference
In C, functions must be declared in a header file before defining them. The Java
compiler allows methods (functions) to be invoked before they are defined.
Miscellaneous Features
Java does not support the following features of C: typedef, variable-length argument
lists (e.g., used in printf () statement ), bitfields, enumerated types, structure and union
types.

Java Environment
.

In Java programming language, all source code is first written in plain text files ending with
the .java extension. Those source files are then compiled into .class files by the javac
compiler. A .class file does not contain code that is native to your processor; it instead
Prof. Mukesh N Tekwani

Page 3 of 6
The Java Programming Language

contains bytecodes — the machine language of the Java Virtual Machine (Java VM). The
java launcher tool then runs your application with an instance of the Java Virtual Machine.
Because the Java VM is available on many different operating systems, the same .class files
are capable of running on Microsoft Windows, the Solaris TM Operating System (Solaris OS),
Linux, or Mac OS.

Java environment includes many tools and classes. The development tools are part the Java
Development Kit (JDK) and the classes and methods are part of the Java Standard Library
(JSL).

Java Development Kit
The JDK includes:
javac –

Java compiler which translates the Java source code into bytecode.

java

–

Java interpreter which runs applications by reading the bytecode files.

jdb

–

Java debugger, which helps in debugging Java code

javap –

Java disassembler, which converts bytecode files into a program description

appletviewer – for viewing Java applets without using a Java-enabled browser

The Java Platform
A platform is the hardware or software environment in which a program runs. Some of the
most popular platforms are Microsoft Windows, Linux, Solaris OS, and Mac OS. Most
platforms can be described as a combination of the operating system and underlying
Page 4 of 6

Java - Chapter 1
The Java Programming Language

hardware. The Java platform differs from most other platforms in that it's a software-only
platform that runs on top of other hardware-based platforms.
The Java platform has two components:
•
•

The Java Virtual Machine
The Java Application Programming Interface (API)

Java Virtual Machine:
Java Virtual Machine is the base for the Java platform and is ported onto various hardwarebased platforms. A Virtual Machine is a software that that creates a virtualized environment
between the computer platform so that the end-user can operate software. Computer platform
includes computer’s hardware, operating system, and programming languages.
The Java Virtual Machine (JVM) is key to the independence of the underlying operating
system and hardware - it is a platform that hides the underlying operating system from Javapowered applets and applications.
1. The Java Virtual Machine, or JVM, is an abstract computer that runs compiled Java
programs.
2. The JVM is "virtual" because it is generally implemented in software on top of a
"real" hardware platform and operating system.
3. All Java programs are compiled for the JVM. Therefore, the JVM must be
implemented on a particular platform before compiled Java programs will run on that
platform.
Compiled Java Programs
Java Virtual Machine
Hardware Platform and Operating System
4. Virtual Machine defines a machine-independent format for binary files called the
class (.class) file format. This format includes instructions for a virtual computer in
the form of bytecodes.

The API
The API is a large collection of ready-made software components that provide many useful
capabilities. It is grouped into libraries of related classes and interfaces; these libraries are
known as packages. The API and Java Virtual Machine insulate the program from the
underlying hardware.

Prof. Mukesh N Tekwani

Page 5 of 6
The Java Programming Language

Advantages of Java
1.
2.
3.
4.
5.
6.

Easy to learn especially for those familiar with C or C++
Programs written in Java are usually smaller than in other languages.
Automatic garbage collection – avoids memory leaks.
Program development time is less in Java.
Platform dependencies can be avoided.
Applications written in Java are complied into machine-independent bytecode, and so
they run consistently on any Java platform.

QUESTIONS
1. Why is Java known as platform-independent language?
2. Explain the term bytecode. Why is Java said to be compiled as well as interpreted?
3. In what way is Java a robust language?
4. Which features of C language are missing from Java? Give at least 5 features.
5. List the components of the JDK. State the function of each of these components.
6. Java is multithreaded, dynamic and extensible. What does this mean for the programmer?
7. In the context of programming languages, define the term “platform”. Elaborate on the
two components of Java platform.

Page 6 of 6

Java - Chapter 1

More Related Content

What's hot

Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for DesignersR. Sosa
 
Introduction to Visual Basic 6.0 Fundamentals
Introduction to Visual Basic 6.0 FundamentalsIntroduction to Visual Basic 6.0 Fundamentals
Introduction to Visual Basic 6.0 FundamentalsSanay Kumar
 
Java and its features
Java and its featuresJava and its features
Java and its featuresPydi Nikhil
 
Java package
Java packageJava package
Java packageCS_GDRCST
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vbSalim M
 
SRS(software requirement specification)
SRS(software requirement specification)SRS(software requirement specification)
SRS(software requirement specification)Akash Kumar Dhameja
 
Java Tutorial Lab 1
Java Tutorial Lab 1Java Tutorial Lab 1
Java Tutorial Lab 1Berk Soysal
 
introduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxintroduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxclassall
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core javamahir jain
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNSU-Biliran Campus
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentationusmankiyani1
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introductionjyoti_lakhani
 

What's hot (20)

Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
 
Introduction to Visual Basic 6.0 Fundamentals
Introduction to Visual Basic 6.0 FundamentalsIntroduction to Visual Basic 6.0 Fundamentals
Introduction to Visual Basic 6.0 Fundamentals
 
Raptor tool
Raptor toolRaptor tool
Raptor tool
 
Java and its features
Java and its featuresJava and its features
Java and its features
 
Java package
Java packageJava package
Java package
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
SRS(software requirement specification)
SRS(software requirement specification)SRS(software requirement specification)
SRS(software requirement specification)
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Java buzzwords.pptx
Java buzzwords.pptxJava buzzwords.pptx
Java buzzwords.pptx
 
Java Tutorial Lab 1
Java Tutorial Lab 1Java Tutorial Lab 1
Java Tutorial Lab 1
 
introduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxintroduction to visual basic PPT.pptx
introduction to visual basic PPT.pptx
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentation
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Java features
Java featuresJava features
Java features
 
Io streams
Io streamsIo streams
Io streams
 
Features of java
Features of javaFeatures of java
Features of java
 

Viewers also liked

Python reading and writing files
Python reading and writing filesPython reading and writing files
Python reading and writing filesMukesh Tekwani
 
Digital signal and image processing FAQ
Digital signal and image processing FAQDigital signal and image processing FAQ
Digital signal and image processing FAQMukesh Tekwani
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingMukesh Tekwani
 
Java chapter 6 - Arrays -syntax and use
Java chapter 6 - Arrays -syntax and useJava chapter 6 - Arrays -syntax and use
Java chapter 6 - Arrays -syntax and useMukesh Tekwani
 
Java chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsJava chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsMukesh Tekwani
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular ExpressionsMukesh Tekwani
 
Data communications ch 1
Data communications   ch 1Data communications   ch 1
Data communications ch 1Mukesh Tekwani
 
Chap 3 data and signals
Chap 3 data and signalsChap 3 data and signals
Chap 3 data and signalsMukesh Tekwani
 
Chapter 26 - Remote Logging, Electronic Mail & File Transfer
Chapter 26 - Remote Logging, Electronic Mail & File TransferChapter 26 - Remote Logging, Electronic Mail & File Transfer
Chapter 26 - Remote Logging, Electronic Mail & File TransferWayne Jones Jnr
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programmingMukesh Tekwani
 

Viewers also liked (19)

Html tables examples
Html tables   examplesHtml tables   examples
Html tables examples
 
Python reading and writing files
Python reading and writing filesPython reading and writing files
Python reading and writing files
 
Jdbc 1
Jdbc 1Jdbc 1
Jdbc 1
 
Java chapter 3
Java   chapter 3Java   chapter 3
Java chapter 3
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Digital signal and image processing FAQ
Digital signal and image processing FAQDigital signal and image processing FAQ
Digital signal and image processing FAQ
 
Java misc1
Java misc1Java misc1
Java misc1
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems Programming
 
Java 1-contd
Java 1-contdJava 1-contd
Java 1-contd
 
Java swing 1
Java swing 1Java swing 1
Java swing 1
 
Java chapter 6 - Arrays -syntax and use
Java chapter 6 - Arrays -syntax and useJava chapter 6 - Arrays -syntax and use
Java chapter 6 - Arrays -syntax and use
 
Java chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsJava chapter 3 - OOPs concepts
Java chapter 3 - OOPs concepts
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular Expressions
 
Html graphics
Html graphicsHtml graphics
Html graphics
 
Data Link Layer
Data Link Layer Data Link Layer
Data Link Layer
 
Data communications ch 1
Data communications   ch 1Data communications   ch 1
Data communications ch 1
 
Chap 3 data and signals
Chap 3 data and signalsChap 3 data and signals
Chap 3 data and signals
 
Chapter 26 - Remote Logging, Electronic Mail & File Transfer
Chapter 26 - Remote Logging, Electronic Mail & File TransferChapter 26 - Remote Logging, Electronic Mail & File Transfer
Chapter 26 - Remote Logging, Electronic Mail & File Transfer
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 

Similar to Java chapter 1

Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to JavaDevaKumari Vijay
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxDrPreethiD1
 
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
 
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
 
0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdfDeepakChaudhriAmbali
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unitgowher172236
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1Qualys
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core javaWE-IT TUTORIALS
 
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
 
java introduction.docx
java introduction.docxjava introduction.docx
java introduction.docxvikasbagra9887
 
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
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objectsvmadan89
 

Similar to Java chapter 1 (20)

Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
 
Java1
Java1Java1
Java1
 
Java
Java Java
Java
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptx
 
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
 
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
 
0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
 
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...
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
java introduction.docx
java introduction.docxjava introduction.docx
java introduction.docx
 
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
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
Java 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENTJava 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENT
 
String class
String classString class
String class
 

More from Mukesh Tekwani

Computer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube ChannelComputer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube ChannelMukesh Tekwani
 
The Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdfThe Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdfMukesh Tekwani
 
ISCE-Class 12-Question Bank - Electrostatics - Physics
ISCE-Class 12-Question Bank - Electrostatics  -  PhysicsISCE-Class 12-Question Bank - Electrostatics  -  Physics
ISCE-Class 12-Question Bank - Electrostatics - PhysicsMukesh Tekwani
 
Hexadecimal to binary conversion
Hexadecimal to binary conversion Hexadecimal to binary conversion
Hexadecimal to binary conversion Mukesh Tekwani
 
Hexadecimal to decimal conversion
Hexadecimal to decimal conversion Hexadecimal to decimal conversion
Hexadecimal to decimal conversion Mukesh Tekwani
 
Hexadecimal to octal conversion
Hexadecimal to octal conversionHexadecimal to octal conversion
Hexadecimal to octal conversionMukesh Tekwani
 
Gray code to binary conversion
Gray code to binary conversion Gray code to binary conversion
Gray code to binary conversion Mukesh Tekwani
 
Decimal to Binary conversion
Decimal to Binary conversionDecimal to Binary conversion
Decimal to Binary conversionMukesh Tekwani
 
Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21Mukesh Tekwani
 
Refraction and dispersion of light through a prism
Refraction and dispersion of light through a prismRefraction and dispersion of light through a prism
Refraction and dispersion of light through a prismMukesh Tekwani
 
Refraction of light at a plane surface
Refraction of light at a plane surfaceRefraction of light at a plane surface
Refraction of light at a plane surfaceMukesh Tekwani
 
Atom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atomAtom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atomMukesh Tekwani
 
Refraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lensesRefraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lensesMukesh Tekwani
 
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGEISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGEMukesh Tekwani
 

More from Mukesh Tekwani (20)

Computer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube ChannelComputer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube Channel
 
The Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdfThe Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdf
 
Circular motion
Circular motionCircular motion
Circular motion
 
Gravitation
GravitationGravitation
Gravitation
 
ISCE-Class 12-Question Bank - Electrostatics - Physics
ISCE-Class 12-Question Bank - Electrostatics  -  PhysicsISCE-Class 12-Question Bank - Electrostatics  -  Physics
ISCE-Class 12-Question Bank - Electrostatics - Physics
 
Hexadecimal to binary conversion
Hexadecimal to binary conversion Hexadecimal to binary conversion
Hexadecimal to binary conversion
 
Hexadecimal to decimal conversion
Hexadecimal to decimal conversion Hexadecimal to decimal conversion
Hexadecimal to decimal conversion
 
Hexadecimal to octal conversion
Hexadecimal to octal conversionHexadecimal to octal conversion
Hexadecimal to octal conversion
 
Gray code to binary conversion
Gray code to binary conversion Gray code to binary conversion
Gray code to binary conversion
 
What is Gray Code?
What is Gray Code? What is Gray Code?
What is Gray Code?
 
Decimal to Binary conversion
Decimal to Binary conversionDecimal to Binary conversion
Decimal to Binary conversion
 
Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21
 
Refraction and dispersion of light through a prism
Refraction and dispersion of light through a prismRefraction and dispersion of light through a prism
Refraction and dispersion of light through a prism
 
Refraction of light at a plane surface
Refraction of light at a plane surfaceRefraction of light at a plane surface
Refraction of light at a plane surface
 
Spherical mirrors
Spherical mirrorsSpherical mirrors
Spherical mirrors
 
Atom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atomAtom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atom
 
Refraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lensesRefraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lenses
 
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGEISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
 
Cyber Laws
Cyber LawsCyber Laws
Cyber Laws
 
XML
XMLXML
XML
 

Recently uploaded

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
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
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
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
 
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
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
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
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Recently uploaded (20)

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
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...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
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
 
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...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
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
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

Java chapter 1

  • 1. 1. THE JAVA PROGRAMMING LANGUAGE What is Java? Java programming language is a high-level language that can be characterized by all of the following buzzwords: • Compiled and Interpreted • Architecture neutral • Distributed • Object oriented • Robust • Secure • Multithreaded • Dynamic • Extensible • High performance • Easy to learn Java features elaborated: 1. Compiled and Interpreted Usually a computer language is either compiled or interpreted. Java combines both these features and thus there are two stages involved in a Java program. First, Java translates the source code into bytecode instructions. Bytecodes are not machine instructions. So in the next stage, the Java interpreter generates the machine code that can be directly executed by the machine that is running the Java program. This interpretation is done by the Java virtual machine. 2. Platform-independent and portable Java programs can be easily moved from one computer system to another. If there are any changes in the OS, processor, and other system resources, there is no need to change the Java program. This portability is achieved in two ways: first Java generates the bytecode instructions that can be run on any machine. Also, the size of the primitive data types are machine independent. This portability is the reason behind the huge success of Java in the networking domain, especially the Internet. We can download an applet from a remote computer to our computer system and execute it locally. 3. Distributed Java was designed with networking in mind. Java programs can share data across networks. Java programs can open and access objects on network devices. 4. Object-oriented Java is object oriented. No coding is permitted outside class definitions. An extensive class library can be used by the programmer 5. Robust Java is a robust language. All local variables must be initialized. There is strong typechecking. That is, all data must be declared explicitly. It has garbage-collection features which means that memory management is no longer something the programmer needs to Java - Chapter 1 Page 1 of 6
  • 2. The Java Programming Language be worried about. Java also does exception handling – serious errors are captured and the risk of crashing the system is minimized. 6. Secure Since Java has been designed for networked environments, security is an important feature of this language. Java systems verify all memory accesses. The absence of pointers in Java ensures that programs do not have access to all memory locations. 7. Multithreaded Multithreading means handling many (multiple) tasks simultaneously. Java handles multithreaded programs. It means that we need not wait for one task to be completed before starting the next task. Such systems are very useful for graphical interactive environments. 8. Dynamic and extensible The linking of data and methods to where they are located, is done at run-time. New classes can be loaded while a program is running. Linking is done on the fly. Even if libraries are recompiled, there is no need to recompile code that uses classes in those libraries. This differs from C++, which uses static binding. By extensible we mean that Java programs can support functions written in other languages such as C or C++. These functions are called native methods. Such functions are linked dynamically at runtime. 9. High performance Even though Java is interpreted (in the second stage), its speed is impressive compared to other interpreted languages. This is due to the use of the intermediate bytecode. Also, the multithreading feature further increases the speed of execution of Java programs. 10. Simple to learn Java is a simple and small language. Many features of C / C++ have been removed from Java. For example, pointers, preprocessor header files (e.g., #include <stdio.h>), goto statement, operator overloading, multiple inheritance, etc have been eliminated from Java. Differences between Java and C: Although Java syntax is in many ways including operators and statements, there are many significant differences in these languages. No preprocessor Java does not include a preprocessor(C and C++ both have the #include preprocessor directive). Also #define, #ifdef are missing from Java. No macro definitions Java does not support macros (#define in C). Page 2 of 6 Java - Chapter 1
  • 3. The Java Programming Language No global variables There are no global variables in Java. Packages contain classes, classes contain fields and methods, and methods contain local variables. Well-defined primitive data types All primitive data types in Java have well-defined sizes. In C, the size of short, int, and long data types is platform-dependent. This hampers portability. No pointers Java does not support the concept of pointers. There is no address-of operator like &, dereference operator like * or −>, or sizeof operator. Pointers are a source of bugs. No goto statement Java doesn't support a goto statement. Use of goto is regarded as poor programming practice. Java adds labeled break and continue statements to the flow-control statements offered by C. These are a good substitute for goto. Garbage collection The Java Virtual Machine performs garbage collection so that Java programmers do not have to explicitly manage the memory used by all objects and arrays. This feature eliminates another entire category of common bugs. It also eliminates memory leaks from Java programs. Variable declarations anywhere C requires local variable declarations to be made at the beginning of a method or block, while Java allows them anywhere in a method or block. Forward Reference In C, functions must be declared in a header file before defining them. The Java compiler allows methods (functions) to be invoked before they are defined. Miscellaneous Features Java does not support the following features of C: typedef, variable-length argument lists (e.g., used in printf () statement ), bitfields, enumerated types, structure and union types. Java Environment . In Java programming language, all source code is first written in plain text files ending with the .java extension. Those source files are then compiled into .class files by the javac compiler. A .class file does not contain code that is native to your processor; it instead Prof. Mukesh N Tekwani Page 3 of 6
  • 4. The Java Programming Language contains bytecodes — the machine language of the Java Virtual Machine (Java VM). The java launcher tool then runs your application with an instance of the Java Virtual Machine. Because the Java VM is available on many different operating systems, the same .class files are capable of running on Microsoft Windows, the Solaris TM Operating System (Solaris OS), Linux, or Mac OS. Java environment includes many tools and classes. The development tools are part the Java Development Kit (JDK) and the classes and methods are part of the Java Standard Library (JSL). Java Development Kit The JDK includes: javac – Java compiler which translates the Java source code into bytecode. java – Java interpreter which runs applications by reading the bytecode files. jdb – Java debugger, which helps in debugging Java code javap – Java disassembler, which converts bytecode files into a program description appletviewer – for viewing Java applets without using a Java-enabled browser The Java Platform A platform is the hardware or software environment in which a program runs. Some of the most popular platforms are Microsoft Windows, Linux, Solaris OS, and Mac OS. Most platforms can be described as a combination of the operating system and underlying Page 4 of 6 Java - Chapter 1
  • 5. The Java Programming Language hardware. The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms. The Java platform has two components: • • The Java Virtual Machine The Java Application Programming Interface (API) Java Virtual Machine: Java Virtual Machine is the base for the Java platform and is ported onto various hardwarebased platforms. A Virtual Machine is a software that that creates a virtualized environment between the computer platform so that the end-user can operate software. Computer platform includes computer’s hardware, operating system, and programming languages. The Java Virtual Machine (JVM) is key to the independence of the underlying operating system and hardware - it is a platform that hides the underlying operating system from Javapowered applets and applications. 1. The Java Virtual Machine, or JVM, is an abstract computer that runs compiled Java programs. 2. The JVM is "virtual" because it is generally implemented in software on top of a "real" hardware platform and operating system. 3. All Java programs are compiled for the JVM. Therefore, the JVM must be implemented on a particular platform before compiled Java programs will run on that platform. Compiled Java Programs Java Virtual Machine Hardware Platform and Operating System 4. Virtual Machine defines a machine-independent format for binary files called the class (.class) file format. This format includes instructions for a virtual computer in the form of bytecodes. The API The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related classes and interfaces; these libraries are known as packages. The API and Java Virtual Machine insulate the program from the underlying hardware. Prof. Mukesh N Tekwani Page 5 of 6
  • 6. The Java Programming Language Advantages of Java 1. 2. 3. 4. 5. 6. Easy to learn especially for those familiar with C or C++ Programs written in Java are usually smaller than in other languages. Automatic garbage collection – avoids memory leaks. Program development time is less in Java. Platform dependencies can be avoided. Applications written in Java are complied into machine-independent bytecode, and so they run consistently on any Java platform. QUESTIONS 1. Why is Java known as platform-independent language? 2. Explain the term bytecode. Why is Java said to be compiled as well as interpreted? 3. In what way is Java a robust language? 4. Which features of C language are missing from Java? Give at least 5 features. 5. List the components of the JDK. State the function of each of these components. 6. Java is multithreaded, dynamic and extensible. What does this mean for the programmer? 7. In the context of programming languages, define the term “platform”. Elaborate on the two components of Java platform. Page 6 of 6 Java - Chapter 1