0% found this document useful (0 votes)
0 views4 pages

Java Notes

Java is a high-level programming language known for its simplicity, platform independence, and object-oriented features. It operates through a Java Virtual Machine (JVM) that executes Java bytecode, with distinctions made between JDK, JRE, and JVM. The document also explains variable types in Java, including local, instance, and static variables, detailing their scope, memory allocation, and access specifications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views4 pages

Java Notes

Java is a high-level programming language known for its simplicity, platform independence, and object-oriented features. It operates through a Java Virtual Machine (JVM) that executes Java bytecode, with distinctions made between JDK, JRE, and JVM. The document also explains variable types in Java, including local, instance, and static variables, detailing their scope, memory allocation, and access specifications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

What is Java?

Java is a high-level programming language.

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

Collection of static web pages.

How the Java works?

What happens at runtime?


At runtime, the following steps are performed:
Classloader: It is the subsystem of JVM that is used to load class files.

Bytecode Verifier: Checks the code fragments for illegal code that can violate access rights
to objects.

Interpreter: Read bytecode stream then execute the instructions.

Difference between JDK, JRE, and JVM


JVM

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:

1. A specification where working of Java Virtual Machine is specified. But


implementation provider is independent to choose the algorithm. Its implementation
has been provided by Oracle and other companies.
2. An implementation Its implementation is known as JRE (Java Runtime
Environment).
3. Runtime Instance Whenever you write java command on the command prompt to
run the java class, an instance of JVM is created.

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:

Declaration – With static keyword in a class, but outside a method, constructor


or block.

Scope – Similar to instance variable i.e. inside the methods, constructor or


block indicating static.

When variables get allocated – when we run program & .class file is loaded,
variable gets allocated. When class file gets unloaded variable gets destroyed.

Store memory – non heap memory or static memory


Default value – similar to instance variable

Access specifier – can be used with variable.

How to access variable – by using class name, by using object reference name,
or directly.

Example –

Class abc

Int a=10;

Static int b=20;

Psvm()

Abc obj=new abc();

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(obj.b); // o/p -2000

Abc ob2=new abc();

Sop(ob2.a); // o/p-10

Sop(ob2.b); // o/p-2000

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy