SlideShare a Scribd company logo
1 of 17
Download to read offline
JAVA
1. What is JAVA?
Java is a high-level programming language and platform.
Platform: Any hardware or software environment in which a program
runs, known as a platform. Since Java has its own Runtime Environment
(JRE) and Application Programming Interface (API), it is called platform.
Developer: James Gosling from Sun Microsystems in 1991.
2. Why JAVA? or Features of JAVA
Java works on different hardware (Device Example: Laptop, System,
Mobile) and software (OS Example: Windows, Mac, Linux, Android).
It is easy to learn and simple to use.
It is open source and free.
It is OOPL.
3. Why JAVA is not fully OOPL?
 In Java, OOPL because without class and object it is impossible to
write any Java program.
 In Java, everything is an object, except primitive data types
because java doesn’t support primitive data type.
 You can access the members of a static class without creating an
object of it.
4. What is JRE components?
JVM, Interpreter, JIT Compiler, Garbage Collector
5. How Java is platform independent?
 JDK it converts .java file into .class file.
 This is known as compilation.
 .class file is an unreadable file it is named as Bytecode.
 This bytecode is given to JRE then JRE inside JVM takes care of
.class file.
 JVM is instance of JRE.
 JVM has JIT compiler with the help of Interpreter .class file is
converted into binary code.
6. Is JRE is platform independent or dependent?
It is a platform dependent and JVM also platform dependent.
7. What are all the backbone of Java language?
JDK, JVM and JRE.
8. Other Programming Vs Java Programming
 In other programming languages: The compiler produces machine
code for a particular system.
 In Java programming language; Java compiler produces code for a
Virtual Machine known as Java Virtual Machine.
 First, Java code is compiled into bytecode.
 This bytecode gets interpreted on different machines
 Between host system and Java source, Bytecode is an intermediary
language.
 JVM is responsible for allocating memory space.
9. What is JVM?
The compiler compiles the Java file into a Java .class file, then that .class
file is input into the JVM, which loads and executes the class file. It
converts Java bytecode into machines language. JVM is instance of JRE.
JVM Architecture:
10.How does JVM Works?
JVM is divided into three main subsystems:
1. ClassLoader Subsystem
1. Loading
1. BootStrap ClassLoader
2. Extension ClassLoader
3. Application ClassLoader
2. Linking
1. Verify
2. Prepare
3. Resolve
3. Initialization
2. Runtime Data Area
1. Method Area
2. Heap Area
3. Stack Area
1. Local Variable Array
2. Operand Stack
3. Frame Data
4. PC Register
5. Native Method Stacks
3. Execution Engine
1. Interpreter
2. JIT Compiler
1. Intermediate Code Generator
2. Code Optimizer
3. Target Code Generator
4. Profiler
3. Garbage Collector
4. Java Native Interface (JNI)/ Native Method Interface
5. Native Method Libraries
ClassLoader Subsystem
Details Description Types
Loading Classes will be loaded by this
component. It will follow
Delegation Hierarchy
Algorithm while loading the
class files.
BootStrap ClassLoader:
Responsible for loading classes
from the bootstrap classpath,
nothing but rt.jar. Highest priority
will be given to this loader.
Extension ClassLoader:
Responsible for loading classes
which are inside the ext
folder (JRElib).
Application ClassLoader:
Responsible for loading
Application Level classpath, path
mentioned Environment Variable,
etc.
Linking After class is loaded by the
classloader, linking is
performed. A bytecode
verifier will verify whether the
generated bytecode is proper or
not if verification fails we will
get a verification error. It also
performs the memory
allocation to static variables
and methods found in the class.
Verify:
Bytecode verifier will verify
whether the generated bytecode is
proper or not if verification fails
we will get the verification error.
Prepare: For all static variables
memory will be allocated and
assigned with default values.
Resolve:
All symbolic memory references
are replaced with the original
references from Method Area.
Initialization This is the final phase of
ClassLoading; here, all static
variables will be assigned with
the original values, and
the static block will be
executed.
No
Runtime Data Area/JVM Memory Area
Types Description
Method 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.
Heap Area 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.
Stack Area 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 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.
1. Local Variable Array – Related to the method how
many local variables are involved and the
corresponding values will be stored here.
2. Operand stack – If any intermediate operation is
required to perform, operand stack acts as runtime
workspace to perform the operation.
3. Frame data – All symbols corresponding to the
method is stored here. In the case of any exception, the
catch block information will be maintained in the
frame data.
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.
Native
Method
Stacks
Native Method Stack holds native method information. For
every thread, a separate native method stack will be created.
Execution Engine
Types Description
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.
JIT
Compiler
The JIT Compiler neutralizes the disadvantage of the
interpreter. The Execution Engine will be using the help of the
interpreter in converting byte code, but when it finds repeated
code it uses the JIT compiler, which compiles the entire
bytecode and changes it to native code. This native code will
be used directly for repeated method calls, which improve the
performance of the system.
1. Intermediate Code Generator – Produces intermediate
code
2. Code Optimizer – Responsible for optimizing the
intermediate code generated above
3. Target Code Generator – Responsible for Generating
Machine Code or Native Code
4. Profiler – A special component, responsible for finding
hotspots, i.e. whether the method is called multiple
times or not.
Garbage
Collector
Collects and removes unreferenced objects. Garbage
Collection can be triggered by calling System.gc(), but the
execution is not guaranteed. Garbage collection of the JVM
collects the objects that are created.
Java Native Interface (JNI):
JNI will be interacting with the Native Method Libraries and provides the
Native Libraries required for the Execution Engine.
Native Method Libraries:
This is a collection of the Native Libraries, which is required for the
Execution Engine.
11. What is JRE?
It is a software package which bundles the libraries (jars) and the Java
Virtual Machine, and other components to run applications written in the Java.
JVM is just a part of JRE distributions. To execute any Java application, you
need JRE installed in the machine. It’s minimum requirement to execute Java
applications on any machine.
JRE bundles the following components –
1. DLL files used by the Java HotSpot Client Virtual Machine.
2. DLL files used by the Java HotSpot Server Virtual Machine.
3. Code libraries, property settings, and resource files used by the Java
runtime environment. e.g. rt.jar and charsets.jar.
4. Java extension files such as localedata.jar.
5. Contains files used for security management. These include the security
policy (java.policy) and security properties (java.security) files.
6. Jar files containing support classes for applets.
7. Contains TrueType font files for use by the platform.
JREs can be downloaded as part of JDKs or you can download them separately.
JREs are platform dependent. It means that based on the type of machine (OS
and architecture), you will have to select the JRE bundle to import and install.
For example, you cannot install a 64-bit JRE distribution on 32-bit machine.
Similarly, JRE distribution for Windows will not work in Linux; and vice-versa.
12.What is JDK?
JDK is a superset of JRE. JDK contains everything that JRE has along with
development tools for developing, debugging, and monitoring Java applications.
You need JDK when you need to develop Java applications.
Few important components shipped with JDKs are as follows:
 appletviewer – this tool can be used to run and debug Java applets without
a web browser
 apt – the annotation-processing tool
 extcheck – a utility that detects JAR file conflicts
 javadoc – the documentation generator, which automatically generates
documentation from source code comments
 jar – the archiver, which packages related class libraries into a single JAR
file. This tool also helps manage JAR files
 jarsigner – the jar signing and verification tool
 javap – the class file disassembler
 javaws – the Java Web Start launcher for JNLP applications
 JConsole – Java Monitoring and Management Console
 jhat – Java Heap Analysis Tool
 jrunscript – Java command-line script shell
 jstack – utility that prints Java stack traces of Java threads
 keytool – tool for manipulating the keystore
 policytool – the policy creation and management tool
 xjc – Part of the Java API for XML Binding (JAXB) API. It accepts an
XML schema and generates Java classes
Same as JREs, JDKs are also platform dependent. So take care when you
download the JDK package for your machine.
13. Why is Java both Interpreted and Compiled Language?
Programming languages are classified as
 Higher Level Language Ex. C++, Java
 Middle-Level Languages Ex. C
 Low-Level Language Ex Assembly
 Finally, the lowest level as the Machine Language.
A compiler is a program which converts a program from one level of language
to another. Example conversion of C++ program into machine code.
The java compiler converts high-level java code into bytecode (which is also a
type of machine code).
An interpreter is a program which converts a program at one level to another
programming language at the same level. Example conversion of Java program
into C++
In Java, the Just in Time Code generator converts the bytecode into the native
machine code which are at the same programming levels.
Hence, Java is both compiled as well as interpreted language.
14. Difference between JDK Vs JRE VS JVM
Functions JDK JRE/Java RTE JVM
Abbreviation Java Development
Kit
Java Runtime
Environment
Java Virtual
Machine
Platform
Independent
No No No
Description It contains JRE +
development tools
like Java libraries,
Java source
compilers, java
debuggers, bundling
and deployment
tools.
It is used to provide
runtime
environment and is
an implementation
of JVM.
JRE = JVM +
Library Files
It is an abstract
machine. It is a
specification that
provides runtime
environment in
which java bytecode
can be executed.
Physical Exists Yes, It is physically
exists and contains
Java tools, JVM,
JRE.
Yes, It contains set
of libraries and
tools.
No, It provides run
time environment to
executes bytecode.
Examples Different Platform
needs different
JDKs.
JREs are also
developed and
released for various
platforms by
different companies
other than Sun
Micro Systems.
There are separate
JVMs for different
OS platforms like
Mac OS, Windows,
Linux etc.
15. Difference between interpreter and JIT compiler?
Interpreter JIT Compiler
It interprets the bytecode line by line and
executes it sequentially.
It helps to execute bytecode faster by
compiling the bytecode to machine code
at runtime.
Execution speed is slower Execution speed is faster
Some Interpreter based languages:
PHP, Perl, Python, Ruby etc.
Used by Java
16. What are the features of Java?
 Simple
 Object Oriented
 Portable
 Platform Independent
 Secured
 Robust
 Architectural Neutral
 Interpreted
 High Performance
 Multithreading
 Distributed
 Dynamic
Simple:
 Java is very easy to learn and its syntax is simple and also easy to
understand.
 Java is simple programming language because it’s syntax is based on
C++, so it is easier for programmers to learn it after C++.
 Java has removed many complicated and rarely used features. Example:
pointers, operator overloading etc.
 There is no need to remove unreferenced objects because there is an
automatic garbage collection in java.
Object Oriented: (What is Object Oriented Programming?)
 It is an OOPL and everything is an object.
 It means we organize our software as a combination of different types of
objects that incorporates both data and behaviour.
 OOPs is a methodology that simplifies software development and
maintenance by providing some rules.
 Basic concept of OOPs is Object, Class, Polymorphism, Abstraction,
Inheritance, Encapsulation.
Platform Independent:
 Java is a platform independent because it source code can run on all
operating systems.
 Slogan for Java is Write Once Run Anywhere (WORA).
 Java code is compiled by the compiler and converted into bytecode.
 This bytecode is a platform independent code because it can run on
multiple platforms.
 What is platform?
 Any hardware or software environment in which a program runs, known
as a platform.
 Since Java has its own Runtime Environment (JRE) and Application
Programming Interface (API), it is called platform.
Secured
 Java is best known for its security and we can develop virus free systems.
 It is secured because no explicit pointer and java programs run inside a
virtual machine.
 In java there is no concept called pointers also hacking java application is
difficult.
OS
Users Runtime
Environment of its own
JVM
Java Application
Physical Address Logical Address
Address name is not changed. Address name is changed.
Route way Not route way
 What is class loader?
 It is a part of JRE which is used to load java classes into the JVM
dynamically.
 It adds security by separating the packages for the classes of the local file
systems from those that are imported from network sources.
 What is bytecode verifier?
 It checks the code fragments for illegal code that can violate access right
to objects.
 What is security manager?
 It determines what resources a class can access such as reading and
writing to the local disk.
Robust:
 It simply means strong.
 Java is robust because it uses strong memory management.
 There is a lack of pointers that avoids security problems.
 There is an automatic garbage collection in java which runs on the JVM
to get rid of objects which are not being used by java application
anymore.
 There are exception handling and type checking mechanism in java.
 All these make java is robust.
Architectural Neutral:
 Java is an architectural neutral because there are no implementation
dependent features. Example: size of primitive data type is fixed.
 In C, integer data type occupies 2 bytes for 32-bit architecture and 4 bytes
for 64-bit architecture.
 In java, integer data type occupies 4 bytes for both 32 and 64-bit
architecture.
 Java doesn’t bother about processor architecture.
 After compilation converting byte code into binary is done inside a JRE.
 So, java is architecture neutral.
Portable:
 Java is portable because it facilitates you to carry the java bytecode to any
platform.
 It doesn’t require any implementation.
High Performance:
 Java is faster than other traditional interpreted programming languages.
 Java bytecode is “close” to native code.
 It is little bit slower than the compiled language (C++).
 Java is an interpreted language that is why it is slower that C++.
Distributed:
 Java is distributed because it facilitates users to create distributed
applications in java.
 Remote Method Invocation (RMI) and Enterprise Java Beans (EJB) are
used for creating distributed applications.
 This feature in java makes us able to access files by calling the methods
from any machine on the internet.
Multi-threading:
 A thread is like a separate programs executing concurrently.
 We can write java programs that deal with many tasks at once by defining
multiple threads.
 Main advantages of multithreading are that it doesn’t occupy memory for
each thread and it shares a common memory area.
Dynamic:
 Java is a dynamic language.
 It supports dynamic loading of classes are loaded on demand and
functions from C and C++.
 It supports dynamic compilation and automatic memory management
(Garbage Collection).
17. What is IDE?
Integrated Development Kit (IDE) is a text editor. In java editors like Eclipse,
NetBeans, Notepad etc.
18. Why Java is platform independent?
 The most unique feature of java is platform independent.
 In any programming language soruce code is compiled in to executable
code. This cannot be run across all platforms.
 When javac compiles a java program it generates an executable file called
.class file. class file contains byte codes.
 Byte codes are interpreted only by JVM’s. Since these JVM’s are made
available across all platforms by Sun Microsystems, we can execute this
byte code in any platform.
 Byte code generated in windows environment can also be executed in
linux environment. This makes java platform independent.
19.What is difference between C++ and Java?
Java C++
It is platform independent Old days it is a platform dependent
but now a days it is platform
independent.
There are no pointers concepts There are pointers concepts
There is no operator overloading in
java
It has operator overloading
There is garbage collection in java There is no garbage collection in C++
Supports multithreading Doesn’t support multithreading
There are no templates in java There are templates in C++
There are no global variables in java There are global variables in C++
20.What is JIT compiler?
 JIT compiler stands for Just in time compiler.
 JIT compiler compiles byte code in to executable code. JIT a part of
JVM.
 JIT cannot convert complete java program in to executable code it
converts as and when it is needed during execution.
21. What is bytecode in java?
 When a javac compiler compiler compiles a class it generates .class file.
 This .class file contains set of instructions called byte code.
 Byte code is a machine independent language and contains set of
instructions which are to be executed only by JVM. JVM can understand
this byte codes.
22. What are the difference between for loop and while loop?
Do While loop While loop For Loop
It is used to
iterate(repetition) a part of
the program several times.
(Exit controlled / Post
Test )
It is used to
iterate(repetition) a part
of the program several
times. (Entry controlled /
Pre Test)
It is used to number of
iterations.
If the number of iteration
is not fixed and you must
have to execute the loop at
least once, it is
recommended to use do
while loop.
If the number of iteration
is not fixed, it is
recommended to use
while loop.
If the number of
iterations is infinite times.
Syntax:
do
{
//code to be executed
}
while(condition)
while(condition)
{
//code to be executed
}
for(initialization;
condition;
increment/decrement)
{
//code to be executed
}
Flow Chart:
Statement
conditionStatement
condition
do
False
True
True False condition
Statement
Increment/Decrement
Initialization
True
False

More Related Content

What's hot

Miscibility and Thermodynamics of Polymer Blends
Miscibility and Thermodynamics of Polymer BlendsMiscibility and Thermodynamics of Polymer Blends
Miscibility and Thermodynamics of Polymer BlendsAbhinand Krishna
 
The Fundamentals of Rheology
The Fundamentals of RheologyThe Fundamentals of Rheology
The Fundamentals of RheologyInstron
 
An introduction to Python for absolute beginners
An introduction to Python for absolute beginnersAn introduction to Python for absolute beginners
An introduction to Python for absolute beginnersKálmán "KAMI" Szalai
 
Classification Of Polymer On Different Basis
Classification Of Polymer On Different BasisClassification Of Polymer On Different Basis
Classification Of Polymer On Different BasisDevansh Gupta
 
Polymer Additives and Blends
Polymer Additives and Blends Polymer Additives and Blends
Polymer Additives and Blends Haseeb Ahmad
 
Polymer Gels (Hydrogels)
Polymer Gels (Hydrogels)Polymer Gels (Hydrogels)
Polymer Gels (Hydrogels)Devansh Gupta
 
Python GUI Programming
Python GUI ProgrammingPython GUI Programming
Python GUI ProgrammingRTS Tech
 
Introduction of polymer
Introduction of polymerIntroduction of polymer
Introduction of polymerRx Ravi Goyani
 
Synthesis and Fabrication of Polymers
Synthesis and Fabrication of PolymersSynthesis and Fabrication of Polymers
Synthesis and Fabrication of PolymersPam Cudal
 
Benefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of pythonBenefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of pythonparadisetechsoftsolutions
 

What's hot (20)

Friend Function
Friend FunctionFriend Function
Friend Function
 
POLYMERS
POLYMERSPOLYMERS
POLYMERS
 
Miscibility and Thermodynamics of Polymer Blends
Miscibility and Thermodynamics of Polymer BlendsMiscibility and Thermodynamics of Polymer Blends
Miscibility and Thermodynamics of Polymer Blends
 
The Fundamentals of Rheology
The Fundamentals of RheologyThe Fundamentals of Rheology
The Fundamentals of Rheology
 
Polyurethane (pu)
Polyurethane (pu)Polyurethane (pu)
Polyurethane (pu)
 
An introduction to Python for absolute beginners
An introduction to Python for absolute beginnersAn introduction to Python for absolute beginners
An introduction to Python for absolute beginners
 
Classification Of Polymer On Different Basis
Classification Of Polymer On Different BasisClassification Of Polymer On Different Basis
Classification Of Polymer On Different Basis
 
Polymer Additives and Blends
Polymer Additives and Blends Polymer Additives and Blends
Polymer Additives and Blends
 
Polymer Gels (Hydrogels)
Polymer Gels (Hydrogels)Polymer Gels (Hydrogels)
Polymer Gels (Hydrogels)
 
Unit 15
Unit 15Unit 15
Unit 15
 
Pultrusion process
Pultrusion  processPultrusion  process
Pultrusion process
 
Python GUI Programming
Python GUI ProgrammingPython GUI Programming
Python GUI Programming
 
Introduction to Polymers
Introduction to PolymersIntroduction to Polymers
Introduction to Polymers
 
polyamides
polyamidespolyamides
polyamides
 
Nylon 66
Nylon 66Nylon 66
Nylon 66
 
Introduction of polymer
Introduction of polymerIntroduction of polymer
Introduction of polymer
 
Synthesis and Fabrication of Polymers
Synthesis and Fabrication of PolymersSynthesis and Fabrication of Polymers
Synthesis and Fabrication of Polymers
 
Engineering polymers
Engineering polymersEngineering polymers
Engineering polymers
 
Python libraries
Python librariesPython libraries
Python libraries
 
Benefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of pythonBenefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of python
 

Similar to Basic Java I

Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machineLaxman Puri
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machineNikhil Sharma
 
Java Virtual Machine - Internal Architecture
Java Virtual Machine - Internal ArchitectureJava Virtual Machine - Internal Architecture
Java Virtual Machine - Internal Architecturesubnesh
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8kumar467
 
Introduction to java programming tutorial
Introduction to java programming   tutorialIntroduction to java programming   tutorial
Introduction to java programming tutorialjackschitze
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting StartedRakesh Madugula
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxMurugesh33
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxMurugesh33
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to JavaAnkita Totala
 
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...Rhythm Suiwal
 
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 Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMshamnasain
 
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
 

Similar to Basic Java I (20)

Java JDK.docx
Java JDK.docxJava JDK.docx
Java JDK.docx
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Java Virtual Machine - Internal Architecture
Java Virtual Machine - Internal ArchitectureJava Virtual Machine - Internal Architecture
Java Virtual Machine - Internal Architecture
 
Java notes
Java notesJava notes
Java notes
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
 
Introduction to java programming tutorial
Introduction to java programming   tutorialIntroduction to java programming   tutorial
Introduction to java programming tutorial
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Jvm internal detail
Jvm internal detailJvm internal detail
Jvm internal detail
 
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
 
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 Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
 
Java lab zero lecture
Java  lab  zero lectureJava  lab  zero lecture
Java lab zero lecture
 
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
 

More from SSN College of Engineering, Kalavakkam

More from SSN College of Engineering, Kalavakkam (20)

ECG
ECG ECG
ECG
 
Localization, Classification, and Evaluation.pdf
Localization, Classification, and Evaluation.pdfLocalization, Classification, and Evaluation.pdf
Localization, Classification, and Evaluation.pdf
 
ADBMS 3a
ADBMS   3aADBMS   3a
ADBMS 3a
 
Exercise 5
Exercise   5Exercise   5
Exercise 5
 
ADBMS Unit-II c
ADBMS Unit-II cADBMS Unit-II c
ADBMS Unit-II c
 
ADBMS Unit-II b
ADBMS Unit-II bADBMS Unit-II b
ADBMS Unit-II b
 
Database Management System - 2a
Database Management System - 2aDatabase Management System - 2a
Database Management System - 2a
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Unit III - Inventory Problems
Unit III - Inventory ProblemsUnit III - Inventory Problems
Unit III - Inventory Problems
 
Unit II B - Game Theory
Unit II B - Game TheoryUnit II B - Game Theory
Unit II B - Game Theory
 
Unit II A - Game Theory
Unit II A - Game TheoryUnit II A - Game Theory
Unit II A - Game Theory
 
Unit V - Queuing Theory
Unit V - Queuing TheoryUnit V - Queuing Theory
Unit V - Queuing Theory
 
Unit IV-Project Management
Unit IV-Project ManagementUnit IV-Project Management
Unit IV-Project Management
 
Unit I-B
Unit I-BUnit I-B
Unit I-B
 
Unit I-A
Unit I-AUnit I-A
Unit I-A
 
Web technology Unit-II Part-C
Web technology Unit-II Part-CWeb technology Unit-II Part-C
Web technology Unit-II Part-C
 
Data structure Unit-I Part-C
Data structure Unit-I Part-CData structure Unit-I Part-C
Data structure Unit-I Part-C
 
Data structure unit I part B
Data structure unit I part BData structure unit I part B
Data structure unit I part B
 
Web technology Unit-II Part A
Web technology Unit-II Part AWeb technology Unit-II Part A
Web technology Unit-II Part A
 
Data structure Unit-I Part A
Data structure Unit-I Part AData structure Unit-I Part A
Data structure Unit-I Part A
 

Recently uploaded

Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 

Recently uploaded (20)

Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 

Basic Java I

  • 1. JAVA 1. What is JAVA? Java is a high-level programming language and platform. Platform: Any hardware or software environment in which a program runs, known as a platform. Since Java has its own Runtime Environment (JRE) and Application Programming Interface (API), it is called platform. Developer: James Gosling from Sun Microsystems in 1991. 2. Why JAVA? or Features of JAVA Java works on different hardware (Device Example: Laptop, System, Mobile) and software (OS Example: Windows, Mac, Linux, Android). It is easy to learn and simple to use. It is open source and free. It is OOPL. 3. Why JAVA is not fully OOPL?  In Java, OOPL because without class and object it is impossible to write any Java program.  In Java, everything is an object, except primitive data types because java doesn’t support primitive data type.  You can access the members of a static class without creating an object of it. 4. What is JRE components? JVM, Interpreter, JIT Compiler, Garbage Collector
  • 2. 5. How Java is platform independent?  JDK it converts .java file into .class file.  This is known as compilation.  .class file is an unreadable file it is named as Bytecode.  This bytecode is given to JRE then JRE inside JVM takes care of .class file.  JVM is instance of JRE.  JVM has JIT compiler with the help of Interpreter .class file is converted into binary code. 6. Is JRE is platform independent or dependent? It is a platform dependent and JVM also platform dependent. 7. What are all the backbone of Java language? JDK, JVM and JRE. 8. Other Programming Vs Java Programming  In other programming languages: The compiler produces machine code for a particular system.  In Java programming language; Java compiler produces code for a Virtual Machine known as Java Virtual Machine.  First, Java code is compiled into bytecode.  This bytecode gets interpreted on different machines  Between host system and Java source, Bytecode is an intermediary language.  JVM is responsible for allocating memory space.
  • 3. 9. What is JVM? The compiler compiles the Java file into a Java .class file, then that .class file is input into the JVM, which loads and executes the class file. It converts Java bytecode into machines language. JVM is instance of JRE. JVM Architecture:
  • 4. 10.How does JVM Works? JVM is divided into three main subsystems: 1. ClassLoader Subsystem 1. Loading 1. BootStrap ClassLoader 2. Extension ClassLoader 3. Application ClassLoader 2. Linking 1. Verify 2. Prepare 3. Resolve 3. Initialization 2. Runtime Data Area 1. Method Area 2. Heap Area 3. Stack Area 1. Local Variable Array 2. Operand Stack 3. Frame Data 4. PC Register 5. Native Method Stacks 3. Execution Engine 1. Interpreter 2. JIT Compiler 1. Intermediate Code Generator 2. Code Optimizer 3. Target Code Generator 4. Profiler 3. Garbage Collector 4. Java Native Interface (JNI)/ Native Method Interface 5. Native Method Libraries
  • 5. ClassLoader Subsystem Details Description Types Loading Classes will be loaded by this component. It will follow Delegation Hierarchy Algorithm while loading the class files. BootStrap ClassLoader: Responsible for loading classes from the bootstrap classpath, nothing but rt.jar. Highest priority will be given to this loader. Extension ClassLoader: Responsible for loading classes which are inside the ext folder (JRElib). Application ClassLoader: Responsible for loading Application Level classpath, path mentioned Environment Variable, etc. Linking After class is loaded by the classloader, linking is performed. A bytecode verifier will verify whether the generated bytecode is proper or not if verification fails we will get a verification error. It also performs the memory allocation to static variables and methods found in the class. Verify: Bytecode verifier will verify whether the generated bytecode is proper or not if verification fails we will get the verification error. Prepare: For all static variables memory will be allocated and assigned with default values. Resolve: All symbolic memory references are replaced with the original references from Method Area. Initialization This is the final phase of ClassLoading; here, all static variables will be assigned with the original values, and the static block will be executed. No
  • 6. Runtime Data Area/JVM Memory Area Types Description Method 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. Heap Area 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. Stack Area 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 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. 1. Local Variable Array – Related to the method how many local variables are involved and the corresponding values will be stored here. 2. Operand stack – If any intermediate operation is required to perform, operand stack acts as runtime workspace to perform the operation. 3. Frame data – All symbols corresponding to the method is stored here. In the case of any exception, the catch block information will be maintained in the frame data. 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. Native Method Stacks Native Method Stack holds native method information. For every thread, a separate native method stack will be created.
  • 7. Execution Engine Types Description 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. JIT Compiler The JIT Compiler neutralizes the disadvantage of the interpreter. The Execution Engine will be using the help of the interpreter in converting byte code, but when it finds repeated code it uses the JIT compiler, which compiles the entire bytecode and changes it to native code. This native code will be used directly for repeated method calls, which improve the performance of the system. 1. Intermediate Code Generator – Produces intermediate code 2. Code Optimizer – Responsible for optimizing the intermediate code generated above 3. Target Code Generator – Responsible for Generating Machine Code or Native Code 4. Profiler – A special component, responsible for finding hotspots, i.e. whether the method is called multiple times or not. Garbage Collector Collects and removes unreferenced objects. Garbage Collection can be triggered by calling System.gc(), but the execution is not guaranteed. Garbage collection of the JVM collects the objects that are created. Java Native Interface (JNI): JNI will be interacting with the Native Method Libraries and provides the Native Libraries required for the Execution Engine. Native Method Libraries: This is a collection of the Native Libraries, which is required for the Execution Engine.
  • 8. 11. What is JRE? It is a software package which bundles the libraries (jars) and the Java Virtual Machine, and other components to run applications written in the Java. JVM is just a part of JRE distributions. To execute any Java application, you need JRE installed in the machine. It’s minimum requirement to execute Java applications on any machine. JRE bundles the following components – 1. DLL files used by the Java HotSpot Client Virtual Machine. 2. DLL files used by the Java HotSpot Server Virtual Machine. 3. Code libraries, property settings, and resource files used by the Java runtime environment. e.g. rt.jar and charsets.jar. 4. Java extension files such as localedata.jar. 5. Contains files used for security management. These include the security policy (java.policy) and security properties (java.security) files. 6. Jar files containing support classes for applets. 7. Contains TrueType font files for use by the platform. JREs can be downloaded as part of JDKs or you can download them separately. JREs are platform dependent. It means that based on the type of machine (OS and architecture), you will have to select the JRE bundle to import and install. For example, you cannot install a 64-bit JRE distribution on 32-bit machine. Similarly, JRE distribution for Windows will not work in Linux; and vice-versa.
  • 9. 12.What is JDK? JDK is a superset of JRE. JDK contains everything that JRE has along with development tools for developing, debugging, and monitoring Java applications. You need JDK when you need to develop Java applications. Few important components shipped with JDKs are as follows:  appletviewer – this tool can be used to run and debug Java applets without a web browser  apt – the annotation-processing tool  extcheck – a utility that detects JAR file conflicts  javadoc – the documentation generator, which automatically generates documentation from source code comments  jar – the archiver, which packages related class libraries into a single JAR file. This tool also helps manage JAR files  jarsigner – the jar signing and verification tool  javap – the class file disassembler  javaws – the Java Web Start launcher for JNLP applications  JConsole – Java Monitoring and Management Console  jhat – Java Heap Analysis Tool  jrunscript – Java command-line script shell  jstack – utility that prints Java stack traces of Java threads  keytool – tool for manipulating the keystore  policytool – the policy creation and management tool  xjc – Part of the Java API for XML Binding (JAXB) API. It accepts an XML schema and generates Java classes Same as JREs, JDKs are also platform dependent. So take care when you download the JDK package for your machine.
  • 10. 13. Why is Java both Interpreted and Compiled Language? Programming languages are classified as  Higher Level Language Ex. C++, Java  Middle-Level Languages Ex. C  Low-Level Language Ex Assembly  Finally, the lowest level as the Machine Language. A compiler is a program which converts a program from one level of language to another. Example conversion of C++ program into machine code. The java compiler converts high-level java code into bytecode (which is also a type of machine code). An interpreter is a program which converts a program at one level to another programming language at the same level. Example conversion of Java program into C++ In Java, the Just in Time Code generator converts the bytecode into the native machine code which are at the same programming levels. Hence, Java is both compiled as well as interpreted language.
  • 11. 14. Difference between JDK Vs JRE VS JVM Functions JDK JRE/Java RTE JVM Abbreviation Java Development Kit Java Runtime Environment Java Virtual Machine Platform Independent No No No Description It contains JRE + development tools like Java libraries, Java source compilers, java debuggers, bundling and deployment tools. It is used to provide runtime environment and is an implementation of JVM. JRE = JVM + Library Files It is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed. Physical Exists Yes, It is physically exists and contains Java tools, JVM, JRE. Yes, It contains set of libraries and tools. No, It provides run time environment to executes bytecode. Examples Different Platform needs different JDKs. JREs are also developed and released for various platforms by different companies other than Sun Micro Systems. There are separate JVMs for different OS platforms like Mac OS, Windows, Linux etc.
  • 12. 15. Difference between interpreter and JIT compiler? Interpreter JIT Compiler It interprets the bytecode line by line and executes it sequentially. It helps to execute bytecode faster by compiling the bytecode to machine code at runtime. Execution speed is slower Execution speed is faster Some Interpreter based languages: PHP, Perl, Python, Ruby etc. Used by Java 16. What are the features of Java?  Simple  Object Oriented  Portable  Platform Independent  Secured  Robust  Architectural Neutral  Interpreted  High Performance  Multithreading  Distributed  Dynamic Simple:  Java is very easy to learn and its syntax is simple and also easy to understand.  Java is simple programming language because it’s syntax is based on C++, so it is easier for programmers to learn it after C++.  Java has removed many complicated and rarely used features. Example: pointers, operator overloading etc.  There is no need to remove unreferenced objects because there is an automatic garbage collection in java. Object Oriented: (What is Object Oriented Programming?)  It is an OOPL and everything is an object.  It means we organize our software as a combination of different types of objects that incorporates both data and behaviour.
  • 13.  OOPs is a methodology that simplifies software development and maintenance by providing some rules.  Basic concept of OOPs is Object, Class, Polymorphism, Abstraction, Inheritance, Encapsulation. Platform Independent:  Java is a platform independent because it source code can run on all operating systems.  Slogan for Java is Write Once Run Anywhere (WORA).  Java code is compiled by the compiler and converted into bytecode.  This bytecode is a platform independent code because it can run on multiple platforms.  What is platform?  Any hardware or software environment in which a program runs, known as a platform.  Since Java has its own Runtime Environment (JRE) and Application Programming Interface (API), it is called platform. Secured  Java is best known for its security and we can develop virus free systems.  It is secured because no explicit pointer and java programs run inside a virtual machine.  In java there is no concept called pointers also hacking java application is difficult. OS Users Runtime Environment of its own JVM Java Application
  • 14. Physical Address Logical Address Address name is not changed. Address name is changed. Route way Not route way  What is class loader?  It is a part of JRE which is used to load java classes into the JVM dynamically.  It adds security by separating the packages for the classes of the local file systems from those that are imported from network sources.  What is bytecode verifier?  It checks the code fragments for illegal code that can violate access right to objects.  What is security manager?  It determines what resources a class can access such as reading and writing to the local disk. Robust:  It simply means strong.  Java is robust because it uses strong memory management.  There is a lack of pointers that avoids security problems.  There is an automatic garbage collection in java which runs on the JVM to get rid of objects which are not being used by java application anymore.  There are exception handling and type checking mechanism in java.  All these make java is robust. Architectural Neutral:  Java is an architectural neutral because there are no implementation dependent features. Example: size of primitive data type is fixed.  In C, integer data type occupies 2 bytes for 32-bit architecture and 4 bytes for 64-bit architecture.  In java, integer data type occupies 4 bytes for both 32 and 64-bit architecture.  Java doesn’t bother about processor architecture.  After compilation converting byte code into binary is done inside a JRE.  So, java is architecture neutral.
  • 15. Portable:  Java is portable because it facilitates you to carry the java bytecode to any platform.  It doesn’t require any implementation. High Performance:  Java is faster than other traditional interpreted programming languages.  Java bytecode is “close” to native code.  It is little bit slower than the compiled language (C++).  Java is an interpreted language that is why it is slower that C++. Distributed:  Java is distributed because it facilitates users to create distributed applications in java.  Remote Method Invocation (RMI) and Enterprise Java Beans (EJB) are used for creating distributed applications.  This feature in java makes us able to access files by calling the methods from any machine on the internet. Multi-threading:  A thread is like a separate programs executing concurrently.  We can write java programs that deal with many tasks at once by defining multiple threads.  Main advantages of multithreading are that it doesn’t occupy memory for each thread and it shares a common memory area. Dynamic:  Java is a dynamic language.  It supports dynamic loading of classes are loaded on demand and functions from C and C++.  It supports dynamic compilation and automatic memory management (Garbage Collection). 17. What is IDE? Integrated Development Kit (IDE) is a text editor. In java editors like Eclipse, NetBeans, Notepad etc.
  • 16. 18. Why Java is platform independent?  The most unique feature of java is platform independent.  In any programming language soruce code is compiled in to executable code. This cannot be run across all platforms.  When javac compiles a java program it generates an executable file called .class file. class file contains byte codes.  Byte codes are interpreted only by JVM’s. Since these JVM’s are made available across all platforms by Sun Microsystems, we can execute this byte code in any platform.  Byte code generated in windows environment can also be executed in linux environment. This makes java platform independent. 19.What is difference between C++ and Java? Java C++ It is platform independent Old days it is a platform dependent but now a days it is platform independent. There are no pointers concepts There are pointers concepts There is no operator overloading in java It has operator overloading There is garbage collection in java There is no garbage collection in C++ Supports multithreading Doesn’t support multithreading There are no templates in java There are templates in C++ There are no global variables in java There are global variables in C++ 20.What is JIT compiler?  JIT compiler stands for Just in time compiler.  JIT compiler compiles byte code in to executable code. JIT a part of JVM.  JIT cannot convert complete java program in to executable code it converts as and when it is needed during execution. 21. What is bytecode in java?  When a javac compiler compiler compiles a class it generates .class file.  This .class file contains set of instructions called byte code.  Byte code is a machine independent language and contains set of instructions which are to be executed only by JVM. JVM can understand this byte codes.
  • 17. 22. What are the difference between for loop and while loop? Do While loop While loop For Loop It is used to iterate(repetition) a part of the program several times. (Exit controlled / Post Test ) It is used to iterate(repetition) a part of the program several times. (Entry controlled / Pre Test) It is used to number of iterations. If the number of iteration is not fixed and you must have to execute the loop at least once, it is recommended to use do while loop. If the number of iteration is not fixed, it is recommended to use while loop. If the number of iterations is infinite times. Syntax: do { //code to be executed } while(condition) while(condition) { //code to be executed } for(initialization; condition; increment/decrement) { //code to be executed } Flow Chart: Statement conditionStatement condition do False True True False condition Statement Increment/Decrement Initialization True False