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

REQUIREMENT ENGINEERING
REQUIREMENT ENGINEERINGREQUIREMENT ENGINEERING
REQUIREMENT ENGINEERINGSaqib Raza
 
Text Editor for System software
Text Editor for System softwareText Editor for System software
Text Editor for System softwarekalaivanan vanan
 
Java Presentation
Java PresentationJava Presentation
Java Presentationpm2214
 
Requirement specification (SRS)
Requirement specification (SRS)Requirement specification (SRS)
Requirement specification (SRS)kunj desai
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)Manisha Keim
 
Software requirements specification
Software requirements specificationSoftware requirements specification
Software requirements specificationlavanya marichamy
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software EngineeringZahoor Khan
 
Intoduction to software engineering part 2
Intoduction to software engineering part 2Intoduction to software engineering part 2
Intoduction to software engineering part 2Rupesh Vaishnav
 
Introduction to software engineering
Introduction to software engineeringIntroduction to software engineering
Introduction to software engineeringHitesh Mohapatra
 
2- THE CHANGING NATURE OF SOFTWARE.pdf
2- THE CHANGING NATURE OF SOFTWARE.pdf2- THE CHANGING NATURE OF SOFTWARE.pdf
2- THE CHANGING NATURE OF SOFTWARE.pdfbcanawakadalcollege
 
Software engineering lecture notes
Software engineering lecture notesSoftware engineering lecture notes
Software engineering lecture notesSiva Ayyakutti
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobGaruda Trainings
 

What's hot (20)

REQUIREMENT ENGINEERING
REQUIREMENT ENGINEERINGREQUIREMENT ENGINEERING
REQUIREMENT ENGINEERING
 
Design notation
Design notationDesign notation
Design notation
 
Text Editor for System software
Text Editor for System softwareText Editor for System software
Text Editor for System software
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Java
JavaJava
Java
 
Requirement specification (SRS)
Requirement specification (SRS)Requirement specification (SRS)
Requirement specification (SRS)
 
Programming in Java
Programming in JavaProgramming in Java
Programming in Java
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Software design
Software designSoftware design
Software design
 
Software requirements specification
Software requirements specificationSoftware requirements specification
Software requirements specification
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software Engineering
 
Intoduction to software engineering part 2
Intoduction to software engineering part 2Intoduction to software engineering part 2
Intoduction to software engineering part 2
 
Software Architecture
Software ArchitectureSoftware Architecture
Software Architecture
 
Unit 2
Unit 2Unit 2
Unit 2
 
Introduction to software engineering
Introduction to software engineeringIntroduction to software engineering
Introduction to software engineering
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
2- THE CHANGING NATURE OF SOFTWARE.pdf
2- THE CHANGING NATURE OF SOFTWARE.pdf2- THE CHANGING NATURE OF SOFTWARE.pdf
2- THE CHANGING NATURE OF SOFTWARE.pdf
 
Software engineering lecture notes
Software engineering lecture notesSoftware engineering lecture notes
Software engineering lecture notes
 
Java features
Java featuresJava features
Java features
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a job
 

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
 
Java features
Java  features Java  features
Java features
 
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
 

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

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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
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
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
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
 

Recently uploaded (20)

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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
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...
 

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