Java Concepts: Class, Object, JVM, JIT & Types of Classes
1. Java Class
A class in Java is a blueprint or prototype from which objects are created. It defines the
structure and behavior (data and methods) that the created objects will have. A class
can contain fields, methods, constructors, blocks, and nested classes.
2. Types of Java Classes
a. Concrete Class
A concrete class is a regular Java class that has complete implementations for all of its
methods. It can be instantiated directly to create objects.
b. Abstract Class
An abstract class is a class that cannot be instantiated on its own and may contain
abstract methods (methods without implementation). It is meant to be extended by
subclasses that provide concrete implementations of its abstract methods.
c. Final Class
A final class cannot be extended (inherited) by any other class. It is declared using the
'final' keyword. This is often used to prevent modification or subclassing of certain
classes.
d. Static Class (Nested Static Class)
Java does not support top-level static classes, but it allows static nested classes inside
another class. A static nested class is associated with its outer class and can access static
members of the outer class.
e. POJO Class (Plain Old Java Object)
A POJO is a simple Java class that does not extend or depend on any specific framework
or class. It is used to hold data with private variables and public getters and setters.
3. Java Object
An object is an instance of a class. It is a real-world entity that has state (attributes) and
behavior (methods). In Java, objects are created using the 'new' keyword followed by
the class constructor.
4. JVM (Java Virtual Machine)
The Java Virtual Machine (JVM) is an abstract computing machine that enables Java
programs to run on any device or OS. It executes the bytecode generated by the Java
compiler and provides a runtime environment with memory management, security, and
platform independence.
5. JIT (Just-In-Time Compiler)
JIT is a part of the JVM that improves the performance of Java applications by compiling
bytecode into native machine code at runtime. This allows frequently executed code to
run much faster after it is compiled just-in-time.