SlideShare a Scribd company logo
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
UNIT-1
[Feature to Java, Java Virtual Machine, Differences between C++ and Java, Part of Java, API Document,
Starting a Java Program. Important Classes, Formatting the Output]
FEATURE TO JAVA
1. Simple: Java is Easy to write and more readable and eye catching. Most of the concepts are
aimilar to C++, thus making Java learning simpler. It removed many confusing and/or
rarely-used features e.g., explicit pointers, operator overloading etc. Pointers and Operator
Overloading are not there in java but were an important part of C++. No need to remove
unreferenced objects because there is Automatic Garbage Collection in java.
2. Object-Oriented: Object-Oriented Programming Language (OOPs) is the methodology
which provide software development and maintenance by using object state, behavior , and
properties. Object Oriented Programming Language must have the following characteristics.
1. Encapsulation
2. Polymorphism
3. Inheritance
4. Abstraction
Java is pure OOP. Language. (while C++ is semi object oriented).
3. Secure: Java enable us to develop virus free, temper free system as it provides security
features like:
1. No explicit use of pointers
2. Every time when a user compiles the Java program, the Java compiler creates
a class file with Bytecode, which are tested by the JVM at the time of
program execution for viruses and other malicious files.
3. The concept of exception handling enables Java to capture a series of errors
that helps developers to get rid of risk of crashing the system.
4. Garbage Collection, etc.
4. Robust: Different security features of Java make this language robust. Java encourages
error-free programming by being strictly typed and performing run-time checks.
5. Platform Independent: Unlike other programming languages such as C, C++ etc which are
compiled into platform specific machines, Java is guaranteed to be write-once, run-
anywhere (WORA) language. On compilation Java program is compiled into bytecode. This
bytecode is platform independent and can be run on any machine, plus this bytecode format
also provide security. Any machine with Java Runtime Environment can run Java Programs.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
6. Architecture-neutral: Java is independent of hardware e.g. size of primitive types is fixed.
In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4
bytes of memory for 64-bit architecture. But in java, it occupies 4 bytes of memory for both
32 and 64 bit architectures.
7. Portable: The portability actually comes from architecture-neutrality. Java programs can
execute in any environment for which there is a Java run-time system (JVM), irrespective of
OS and hardware.
8. Multi-Threading: A thread is like a separate program, executing concurrently. Java
multithreading feature makes it possible to write program that can do many tasks
simultaneously. Benefit of multithreading is that it utilizes same memory and other
resources to execute multiple threads at the same time, like While typing, grammatical
errors are checked along.
9. High Performance: Java enables the creation of cross-platform programs with the help of
Byte code (Intermediate code). Most previos attempts for implementing cross-plaform
solutions compromise the performance parameter. But, Java bytecode was carefully
designed for easy and direct translation into native machine code by using Just-in-time
compiler for very high perfomance.
10. Distributed: Java is designed for the distributed environment of the internet because it
handles TCP/IP protocols. It also enables support for Remote Method Invocation (RMI),
which helps to invoke methods across a network.
JAVA VIRTUAL MACHINE
The overall development and execution infrastructure for a Java program is shown in following
figure. A program written in the Java programming language is compiled into a set of bytecodes.
Those bytecodes are then loaded and executed by a JVM. If the program makes calls to other Java
classes, the bytecodes for those classes will likewise be loaded, dynamically linked, and executed.
The Java Development Kit (JDK) provides software development environment for developing
Java applications. It includes JRE, java compiler and other required development tools.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
JRE stands for “Java Runtime Environment” and may also be written as “Java RTE.” The Java
Runtime Environment provides the minimum requirements for executing a Java application; it
consists of the Java Virtual Machine (JVM), java interpreter and required libraries to run java
application.
JVM is short for Java Virtual Machine. JVM is an abstract computing machine, or virtual machine
or a machine within a machine – which acts like a real Java processor and provides a a
recommended environment to execute java bytecode. It needs the Java code library to run
applications. JVM only works with bytecode. Hence we need to compile our Java application
(.java) so that it can be converted to bytecode format (.class file).
JVM enabling Java bytecode to be executed as actions or operating system calls on any processor
regardless of the operating system. For example, establishing a socket connection from a
workstation to a remote machine involves an operating system call. Since different operating
systems handle sockets in different ways, the JVM translates the programming code so that the two
machines that may be on different platforms are able to connect.
JVM, JRE and JDK are platform dependent because configuration of each OS differs. But,
Java is platform independent.
Internal Architecture of JVM
Let's understand the internal architecture of JVM. It contains classloader, memory area, execution
engine etc. Diagrammatic representation is shown in next page.
1. Classloader: is a subsystem of JVM that is used to load class files.It loads, links. And
initializes the class file when it refers to a class for the first time at runtime, not compile
time.
2. JVM Memory Area: It is divided into 5 major components:
1. Method/Class Area – All the class level data will be stored here, including static
variables. There is only one method area per JVM, and it is a shared resource.
2. Heap: All the Objects and their corresponding instance variables and arrays will
be stored here. There is also one Heap Area per JVM. Since the Method and Heap
areas share memory for multiple threads, the data stored is not thread safe.
3. Stack: For every thread, a separate runtime stack will be created. For every
method call, one entry will be made in the stack memory which is called as Stack
Frame. All local variables will be created in the stack memory. The stack area is
thread safe since it is not a shared resource.
4. PC Registers: Each thread will have separate PC Registers, to hold the address of
current executing instruction. Once the instruction is executed the PC register will
be updated with the next instruction.
5. Native Method stacks: Native Method Stack holds native method information used
in the application. For every thread, a separate native method stack will be created.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
3. Execution Engine: The bytecode which is assigned to the JVM Memory Area will be
executed by the Execution Engine. The Execution Engine reads the bytecode and executes
it piece by piece. It contains:
1. Interpreter– The interpreter interprets the bytecode faster, but executes slowly. The
disadvantage of the interpreter is that when one method is called multiple times,
every time a new interpretation is required.
2. JIT Compiler– The JIT Compiler neutralizes the disadvantage of the interpreter by
improving the performance. JIT compiles parts of the byte code that have similar
functionality at the same time, and hence reduces the amount of time needed for
compilation.Here the term “compiler” refers to a translator from the instruction set
of a Java virtual machine (JVM) to the instruction set of a specific CPU.
3. Garbage Collector– It Collects and removes unreferenced objects. Garbage
Collection can be triggered by calling "System.gc()", but the execution is not
guaranteed.
4. Java Native Method Interface: It will be interacting with the Native Method Libraries.
5. Native Method Libraries: It is a collection of the Native Libraries which is required for
the Execution Engine.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
DIFFERENCES BETWEEN C++ AND JAVA
C++ JAVA
1.
C++ was developed by Bjarne Stroustrup.
Development began in 1979.
Java was developed by James Gosling
and his team. Development began in
1991.
2. C++ is a compiled language. Java is both compiled and interpreted.
3.
C++ programs are platform dependent. They need
to be compiled for a particular platform.
Java programs are platform independent.
Java programs are written for Java
Virtual Machine (JVM) and wherever a
JVM is installed, Java program will run
without needing recompilation.
4.
C++ does support operator overloading. Function
overloading is also available.
Java does not support operator
overloading. However, function
overloading is possible.
5. C++ fully supports pointers.
Java supports pointer internally. But you
can't write the pointer program in java.
6. C++ supports structures and unions.
Java does not support structures and
unions.
7. C++ does not have built-in support for threads. Java fully supports threads.
8.
C++ supports manual object management through
new and deletekeywords.
Java relies on automatic garbage
collection. It does not support destructors
the way C++ does.
9.
C++ supports goto statement (however the use of
goto is discouraged as not considered a good
practice)
Java does not support goto statement
(although goto is a reserved keyword in
Java)
10. C++ supports multiple inheritance.
Java does not really support multiple
inheritance. But similar results can be
achieved through the use of interfaces.
11.
C++ provides support both for call by value and call
by reference.
Java supports only call by value.
12.
C++ provides virtual keyword to support function
overriding.
Java does not support virtual keyword.
All the non-static Java functions are by
default virtual in nature, and therefore,
can be overridden.
13. C++ is mainly used for system programming.
Java is mainly used for application
programming. It is widely used in
window, web-based, enterprise and
mobile applications.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
API Document
An application programming interface (API), in the context of Java, is a collection of prewritten
packages, classes, and interfaces with their respective methods, fields and constructors. In Java,
most basic programming tasks are performed by the API’s classes and packages, which are helpful
in minimizing the number of lines written within pieces of code.
The API is a library of available Java classes, packages and interfaces. The three API types are as
follows:
• Official Java core API, which is bundled with the JDK download
• Optional official Java APIs, which may be downloaded if needed
• Unofficial APIs, which are third-party APIs that may be downloaded from source websites
The official API includes packages, e.g., applet packages, graphics and GUI swing packages,
input/output (IO) packages and Abstract Windows Toolkit (AWT), among others.
Important Classes
• The System (java.lang.System) class contains several useful class fields and methods for
standard input, standard output, and error output streams. It cannot be instantiated.
• The java.lang.String class provides a lot of methods to work on string. By the help of these
methods, we can perform operations on string such as trimming, concatenating, converting,
comparing, replacing strings etc.
• Scanner is a class in java.util package used for obtaining the input of the primitive types
like int, double etc. and strings. It is the easiest way to read input in a Java program.
• The Object class (java.lang.Object) is the parent class of all the classes in java by default. In
other words, it is the topmost class of java.
Provided By Shipra Swati
Ad

More Related Content

What's hot (20)

INTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATIONINTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATION
Ajit Yadav
 
Bn1005 demo ppt core java
Bn1005 demo ppt core javaBn1005 demo ppt core java
Bn1005 demo ppt core java
conline training
 
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
 
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
Indika Munaweera Kankanamge
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
sshhzap
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
jyoti_lakhani
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
Learn Java Part 1
Learn Java Part 1Learn Java Part 1
Learn Java Part 1
Gurpreet singh
 
Introduction To Java.
Introduction To Java.Introduction To Java.
Introduction To Java.
Tushar Chauhan
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
Abir Mohammad
 
Introducing Java 7
Introducing Java 7Introducing Java 7
Introducing Java 7
Markus Eisele
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
Md. Tanvir Hossain
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Elizabeth alexander
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Sandeep Rawat
 
Java features
Java featuresJava features
Java features
myrajendra
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
sunmitraeducation
 
1 Introduction To Java Technology
1 Introduction To Java Technology 1 Introduction To Java Technology
1 Introduction To Java Technology
dM Technologies
 
Java
JavaJava
Java
Harry Potter
 
Important features of java
Important features of javaImportant features of java
Important features of java
AL- AMIN
 
Grade 8: Introduction To Java
Grade 8: Introduction To JavaGrade 8: Introduction To Java
Grade 8: Introduction To Java
nandanrocker
 
INTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATIONINTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATION
Ajit Yadav
 
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
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
sshhzap
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
jyoti_lakhani
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
Abir Mohammad
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Sandeep Rawat
 
1 Introduction To Java Technology
1 Introduction To Java Technology 1 Introduction To Java Technology
1 Introduction To Java Technology
dM Technologies
 
Important features of java
Important features of javaImportant features of java
Important features of java
AL- AMIN
 
Grade 8: Introduction To Java
Grade 8: Introduction To JavaGrade 8: Introduction To Java
Grade 8: Introduction To Java
nandanrocker
 

Similar to Java unit 1 (20)

Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
Harsha Batra
 
Java2020 programming basics and fundamentals
Java2020 programming basics and fundamentalsJava2020 programming basics and fundamentals
Java2020 programming basics and fundamentals
swecsaleem
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
RahulAnand111531
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
gowher172236
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
WE-IT TUTORIALS
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
Mukesh Tekwani
 
2 22CA026_Advance Java Programming_Data types and Operators.pptx
2 22CA026_Advance Java Programming_Data types and Operators.pptx2 22CA026_Advance Java Programming_Data types and Operators.pptx
2 22CA026_Advance Java Programming_Data types and Operators.pptx
dolphiverma80
 
Unit-IV_Introduction to Java.pdf
Unit-IV_Introduction to Java.pdfUnit-IV_Introduction to Java.pdf
Unit-IV_Introduction to Java.pdf
Assistant Professor, Shri Shivaji Science College, Amravati
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
ijaprr_editor
 
Java lab lecture 1
Java  lab  lecture 1Java  lab  lecture 1
Java lab lecture 1
vishal choudhary
 
Java Introduction | PDF
Java Introduction |  PDFJava Introduction |  PDF
Java Introduction | PDF
Geekster
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
Murugesh33
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 
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
SuganthiDPSGRKCW
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 java
John Rojas
 
Iintroduction to java , Java Coding , basics of java.pptx
Iintroduction to java , Java Coding , basics of java.pptxIintroduction to java , Java Coding , basics of java.pptx
Iintroduction to java , Java Coding , basics of java.pptx
MayankParashar31
 
J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01
Jay Palit
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
Mohit Belwal
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
Qualys
 
Advanced java training in bangalore
Advanced java training in bangaloreAdvanced java training in bangalore
Advanced java training in bangalore
siyaram ray
 
Java2020 programming basics and fundamentals
Java2020 programming basics and fundamentalsJava2020 programming basics and fundamentals
Java2020 programming basics and fundamentals
swecsaleem
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
gowher172236
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
WE-IT TUTORIALS
 
2 22CA026_Advance Java Programming_Data types and Operators.pptx
2 22CA026_Advance Java Programming_Data types and Operators.pptx2 22CA026_Advance Java Programming_Data types and Operators.pptx
2 22CA026_Advance Java Programming_Data types and Operators.pptx
dolphiverma80
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
ijaprr_editor
 
Java Introduction | PDF
Java Introduction |  PDFJava Introduction |  PDF
Java Introduction | PDF
Geekster
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
Murugesh33
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 
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
SuganthiDPSGRKCW
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 java
John Rojas
 
Iintroduction to java , Java Coding , basics of java.pptx
Iintroduction to java , Java Coding , basics of java.pptxIintroduction to java , Java Coding , basics of java.pptx
Iintroduction to java , Java Coding , basics of java.pptx
MayankParashar31
 
J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01
Jay Palit
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
Mohit Belwal
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
Qualys
 
Advanced java training in bangalore
Advanced java training in bangaloreAdvanced java training in bangalore
Advanced java training in bangalore
siyaram ray
 
Ad

More from Shipra Swati (20)

Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
Shipra Swati
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
Shipra Swati
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-Introduction
Shipra Swati
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
Shipra Swati
 
Java unit 14
Java unit 14Java unit 14
Java unit 14
Shipra Swati
 
Java unit 12
Java unit 12Java unit 12
Java unit 12
Shipra Swati
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
Shipra Swati
 
Java unit 3
Java unit 3Java unit 3
Java unit 3
Shipra Swati
 
Java unit 2
Java unit 2Java unit 2
Java unit 2
Shipra Swati
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
Shipra Swati
 
Ai lab manual
Ai lab manualAi lab manual
Ai lab manual
Shipra Swati
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
Shipra Swati
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
Shipra Swati
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
Shipra Swati
 
Fundamental of Information Technology
Fundamental of Information TechnologyFundamental of Information Technology
Fundamental of Information Technology
Shipra Swati
 
Disk Management
Disk ManagementDisk Management
Disk Management
Shipra Swati
 
File Systems
File SystemsFile Systems
File Systems
Shipra Swati
 
Memory Management
Memory ManagementMemory Management
Memory Management
Shipra Swati
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
Shipra Swati
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
Shipra Swati
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
Shipra Swati
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
Shipra Swati
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-Introduction
Shipra Swati
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
Shipra Swati
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
Shipra Swati
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
Shipra Swati
 
Fundamental of Information Technology
Fundamental of Information TechnologyFundamental of Information Technology
Fundamental of Information Technology
Shipra Swati
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
Shipra Swati
 
Ad

Recently uploaded (20)

Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control
 
Frontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend EngineersFrontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend Engineers
Michael Hertzberg
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
Guru Nanak Technical Institutions
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation RateModeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Journal of Soft Computing in Civil Engineering
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Journal of Soft Computing in Civil Engineering
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Journal of Soft Computing in Civil Engineering
 
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
AI Publications
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
Frontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend EngineersFrontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend Engineers
Michael Hertzberg
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
AI Publications
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 

Java unit 1

  • 1. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE UNIT-1 [Feature to Java, Java Virtual Machine, Differences between C++ and Java, Part of Java, API Document, Starting a Java Program. Important Classes, Formatting the Output] FEATURE TO JAVA 1. Simple: Java is Easy to write and more readable and eye catching. Most of the concepts are aimilar to C++, thus making Java learning simpler. It removed many confusing and/or rarely-used features e.g., explicit pointers, operator overloading etc. Pointers and Operator Overloading are not there in java but were an important part of C++. No need to remove unreferenced objects because there is Automatic Garbage Collection in java. 2. Object-Oriented: Object-Oriented Programming Language (OOPs) is the methodology which provide software development and maintenance by using object state, behavior , and properties. Object Oriented Programming Language must have the following characteristics. 1. Encapsulation 2. Polymorphism 3. Inheritance 4. Abstraction Java is pure OOP. Language. (while C++ is semi object oriented). 3. Secure: Java enable us to develop virus free, temper free system as it provides security features like: 1. No explicit use of pointers 2. Every time when a user compiles the Java program, the Java compiler creates a class file with Bytecode, which are tested by the JVM at the time of program execution for viruses and other malicious files. 3. The concept of exception handling enables Java to capture a series of errors that helps developers to get rid of risk of crashing the system. 4. Garbage Collection, etc. 4. Robust: Different security features of Java make this language robust. Java encourages error-free programming by being strictly typed and performing run-time checks. 5. Platform Independent: Unlike other programming languages such as C, C++ etc which are compiled into platform specific machines, Java is guaranteed to be write-once, run- anywhere (WORA) language. On compilation Java program is compiled into bytecode. This bytecode is platform independent and can be run on any machine, plus this bytecode format also provide security. Any machine with Java Runtime Environment can run Java Programs. Provided By Shipra Swati
  • 2. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE 6. Architecture-neutral: Java is independent of hardware e.g. size of primitive types is fixed. In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4 bytes of memory for 64-bit architecture. But in java, it occupies 4 bytes of memory for both 32 and 64 bit architectures. 7. Portable: The portability actually comes from architecture-neutrality. Java programs can execute in any environment for which there is a Java run-time system (JVM), irrespective of OS and hardware. 8. Multi-Threading: A thread is like a separate program, executing concurrently. Java multithreading feature makes it possible to write program that can do many tasks simultaneously. Benefit of multithreading is that it utilizes same memory and other resources to execute multiple threads at the same time, like While typing, grammatical errors are checked along. 9. High Performance: Java enables the creation of cross-platform programs with the help of Byte code (Intermediate code). Most previos attempts for implementing cross-plaform solutions compromise the performance parameter. But, Java bytecode was carefully designed for easy and direct translation into native machine code by using Just-in-time compiler for very high perfomance. 10. Distributed: Java is designed for the distributed environment of the internet because it handles TCP/IP protocols. It also enables support for Remote Method Invocation (RMI), which helps to invoke methods across a network. JAVA VIRTUAL MACHINE The overall development and execution infrastructure for a Java program is shown in following figure. A program written in the Java programming language is compiled into a set of bytecodes. Those bytecodes are then loaded and executed by a JVM. If the program makes calls to other Java classes, the bytecodes for those classes will likewise be loaded, dynamically linked, and executed. The Java Development Kit (JDK) provides software development environment for developing Java applications. It includes JRE, java compiler and other required development tools. Provided By Shipra Swati
  • 3. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE JRE stands for “Java Runtime Environment” and may also be written as “Java RTE.” The Java Runtime Environment provides the minimum requirements for executing a Java application; it consists of the Java Virtual Machine (JVM), java interpreter and required libraries to run java application. JVM is short for Java Virtual Machine. JVM is an abstract computing machine, or virtual machine or a machine within a machine – which acts like a real Java processor and provides a a recommended environment to execute java bytecode. It needs the Java code library to run applications. JVM only works with bytecode. Hence we need to compile our Java application (.java) so that it can be converted to bytecode format (.class file). JVM enabling Java bytecode to be executed as actions or operating system calls on any processor regardless of the operating system. For example, establishing a socket connection from a workstation to a remote machine involves an operating system call. Since different operating systems handle sockets in different ways, the JVM translates the programming code so that the two machines that may be on different platforms are able to connect. JVM, JRE and JDK are platform dependent because configuration of each OS differs. But, Java is platform independent. Internal Architecture of JVM Let's understand the internal architecture of JVM. It contains classloader, memory area, execution engine etc. Diagrammatic representation is shown in next page. 1. Classloader: is a subsystem of JVM that is used to load class files.It loads, links. And initializes the class file when it refers to a class for the first time at runtime, not compile time. 2. JVM Memory Area: It is divided into 5 major components: 1. Method/Class Area – All the class level data will be stored here, including static variables. There is only one method area per JVM, and it is a shared resource. 2. Heap: All the Objects and their corresponding instance variables and arrays will be stored here. There is also one Heap Area per JVM. Since the Method and Heap areas share memory for multiple threads, the data stored is not thread safe. 3. Stack: For every thread, a separate runtime stack will be created. For every method call, one entry will be made in the stack memory which is called as Stack Frame. All local variables will be created in the stack memory. The stack area is thread safe since it is not a shared resource. 4. PC Registers: Each thread will have separate PC Registers, to hold the address of current executing instruction. Once the instruction is executed the PC register will be updated with the next instruction. 5. Native Method stacks: Native Method Stack holds native method information used in the application. For every thread, a separate native method stack will be created. Provided By Shipra Swati
  • 4. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE 3. Execution Engine: The bytecode which is assigned to the JVM Memory Area will be executed by the Execution Engine. The Execution Engine reads the bytecode and executes it piece by piece. It contains: 1. Interpreter– The interpreter interprets the bytecode faster, but executes slowly. The disadvantage of the interpreter is that when one method is called multiple times, every time a new interpretation is required. 2. JIT Compiler– The JIT Compiler neutralizes the disadvantage of the interpreter by improving the performance. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.Here the term “compiler” refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU. 3. Garbage Collector– It Collects and removes unreferenced objects. Garbage Collection can be triggered by calling "System.gc()", but the execution is not guaranteed. 4. Java Native Method Interface: It will be interacting with the Native Method Libraries. 5. Native Method Libraries: It is a collection of the Native Libraries which is required for the Execution Engine. Provided By Shipra Swati
  • 5. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE DIFFERENCES BETWEEN C++ AND JAVA C++ JAVA 1. C++ was developed by Bjarne Stroustrup. Development began in 1979. Java was developed by James Gosling and his team. Development began in 1991. 2. C++ is a compiled language. Java is both compiled and interpreted. 3. C++ programs are platform dependent. They need to be compiled for a particular platform. Java programs are platform independent. Java programs are written for Java Virtual Machine (JVM) and wherever a JVM is installed, Java program will run without needing recompilation. 4. C++ does support operator overloading. Function overloading is also available. Java does not support operator overloading. However, function overloading is possible. 5. C++ fully supports pointers. Java supports pointer internally. But you can't write the pointer program in java. 6. C++ supports structures and unions. Java does not support structures and unions. 7. C++ does not have built-in support for threads. Java fully supports threads. 8. C++ supports manual object management through new and deletekeywords. Java relies on automatic garbage collection. It does not support destructors the way C++ does. 9. C++ supports goto statement (however the use of goto is discouraged as not considered a good practice) Java does not support goto statement (although goto is a reserved keyword in Java) 10. C++ supports multiple inheritance. Java does not really support multiple inheritance. But similar results can be achieved through the use of interfaces. 11. C++ provides support both for call by value and call by reference. Java supports only call by value. 12. C++ provides virtual keyword to support function overriding. Java does not support virtual keyword. All the non-static Java functions are by default virtual in nature, and therefore, can be overridden. 13. C++ is mainly used for system programming. Java is mainly used for application programming. It is widely used in window, web-based, enterprise and mobile applications. Provided By Shipra Swati
  • 6. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE API Document An application programming interface (API), in the context of Java, is a collection of prewritten packages, classes, and interfaces with their respective methods, fields and constructors. In Java, most basic programming tasks are performed by the API’s classes and packages, which are helpful in minimizing the number of lines written within pieces of code. The API is a library of available Java classes, packages and interfaces. The three API types are as follows: • Official Java core API, which is bundled with the JDK download • Optional official Java APIs, which may be downloaded if needed • Unofficial APIs, which are third-party APIs that may be downloaded from source websites The official API includes packages, e.g., applet packages, graphics and GUI swing packages, input/output (IO) packages and Abstract Windows Toolkit (AWT), among others. Important Classes • The System (java.lang.System) class contains several useful class fields and methods for standard input, standard output, and error output streams. It cannot be instantiated. • The java.lang.String class provides a lot of methods to work on string. By the help of these methods, we can perform operations on string such as trimming, concatenating, converting, comparing, replacing strings etc. • Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double etc. and strings. It is the easiest way to read input in a Java program. • The Object class (java.lang.Object) is the parent class of all the classes in java by default. In other words, it is the topmost class of java. Provided By Shipra Swati
  翻译: