Java Notes
Java Notes
Features:
1. Simple
2. Platform Independent
3. Portable
4. Secured
5. Robust
6. Architecture neutral
7. Interpreted
8. High Performance
9. Multithreaded
10. Distributed
11. Dynamic
12. Object Oriented
Web Application
An application that runs on the server side and creates a dynamic page is called a web application.
Web site
Bytecode Verifier: Checks the code fragments for illegal code that can violate access rights
to objects.
JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine because it doesn't
physically exist. It is a specification that provides a runtime environment in which Java bytecode can
be executed. It can also run those programs which are written in other languages and compiled to
Java bytecode.
JVMs are available for many hardware and software platforms. JVM, JRE, and JDK are platform
dependent because the configuration of each OS is different from each other. However, Java is
platform independent.
There are three notions of the JVM: specification, implementation, and instance.
It is:
Variables:
1. Local:
Declaration – Insied methods, constructor or blocks
Scope- Inside method, constructor or block not outside
When gets allocated: When constructor or block, method gets executed.
When your pointer gets out of the block then variable gets destroyed.
Stored memory – Always stored in stack memory.
Default values – Doesn’t have any default values.
Value should be provided before use.
Access specifier – can not be used with local variables.
2. Instance:
Declaration – Inside the class but outside the method, constructors or blocks.
Scope – Inside all the methods, blocks and Constructor within a class (not
inside the static method directly.
When Variables get allocated – When object gets created.
When object gets destroyed variables release memory.
Stored Memory – Always Heap memory
Default values – They have default values like – for int – 0, Boolean – false,
object – null.
Access specifiers – can be used
How to access – simple method – it can called directly
For static method – object.instance variable name.
3. Static Variable:
When variables get allocated – when we run program & .class file is loaded,
variable gets allocated. When class file gets unloaded variable gets destroyed.
How to access variable – by using class name, by using object reference name,
or directly.
Example –
Class abc
Int a=10;
Psvm()
Sop(obj.a); // o/p-10
Sop(obj.b); // o/p-20
Obj.a=1000;
Obj.b=2000;
Sop(obj.a); // o/p-1000
Sop(ob2.a); // o/p-10
Sop(ob2.b); // o/p-2000