Java Basic 

1. JDK , JVM , JRE
2. Java Class
3. Object 




JDK, JVM, and JRE are three important components that play distinct roles in the development and execution of Java applications:


 1. JDK (Java Development Kit): The JDK is a software development kit provided by Oracle that includes all the tools necessary for developing Java applications. It contains the Java compiler (javac), runtime libraries, debugging tools, and other utilities needed for creating and packaging Java programs. The JDK is essential for developers as it provides a complete set of tools to write, compile, and debug Java code.

 2. JVM (Java Virtual Machine): The JVM is the runtime environment in which Java applications are executed. It is responsible for interpreting and executing Java bytecode. The JVM acts as an abstraction layer between the compiled Java code (bytecode) and the underlying hardware and operating system. It provides various runtime services such as memory management, garbage collection, and security. The JVM ensures that Java programs can run on any platform or operating system, making Java a “write once, run anywhere” language.

 3. JRE (Java Runtime Environment): The JRE is a subset of the JDK and is required to run Java applications. It consists of the JVM along with core class libraries and runtime resources. The JRE does not include development tools like the compiler; it is primarily used by end-users who only need to run Java applications. When you install Java on your computer, you typically install the JRE.


In summary, the JDK is used by developers to create Java applications, the JVM is responsible for executing Java bytecode, and the JRE provides the necessary runtime environment to run Java applications.

What is Class in Java ?

A Java class is a blueprint or template that defines the structure and behavior of objects. It serves as a fundamental building block of Java programs and follows the object-oriented programming (OOP) paradigm.

every java program consists one or more classes. Each class encapsulates data (known as instance variables) and methods (functions or behaviors) that operate on that data. The data and methods within a class are defined as members of the class

example of a Java class:

public class Person {

}


Classes are the building blocks of Java programs, enabling the creation of objects with their own state and behavior. They facilitate code organization, reusability, and support various OOP principles like encapsulation, inheritance, and polymorphism.

What is Object ?

Object is an instance of a class. It represents a specific entity that has state (data) and behavior (methods) defined by its class. In other words, an object is a concrete realization of a class blueprint.

When you create an object in Java, you are instantiating a class to create a unique instance with its own set of data and behavior. Each object of a class has its own set of instance variables (also known as fields or attributes), which hold specific values that define the state of the object. The object’s behavior is defined by the methods (member functions) of its class.


public class Main{ // class name as Main

    int x=01; // taking a variable X

    public static void main (String[]args){ // main method

        Main obj = new Main(); // creating an object class name - reference name = new keyword , constructor ()

        System.out.println(obj.x);

     }

}