Java program for beginners

Introduction to Java
Java is defined by a specification and consists of a programming language, a compiler, core libraries and a runtime (Java virtual machine) The Java runtime allows software developers to write program code in other languages than the Java programming language which still runs on the Java virtual machine. The Java platform is usually associated with the Java virtual machine and the Java core libraries.
Properties of Java
• Platform independent
• Object-orientated programming language
• Strongly-typed programming language
• Interpreted and compiled language
• Automatic memory management

Java virtual machine

The Java virtual machine (JVM) is a software implementation of a computer that executes programs like a real machine.

The Java virtual machine is written specifically for a specific operating system, e.g., for Linux, a special implementation is required as well as for Windows.
Classes in Java
The class is a group of similar entities. It is only a logical component and not the physical entity.

A class can contain any of the following variable types.

Local variables − Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed.

Instance variables − Instance variables are variables within a class but outside any method. These variables are initialized when the class is instantiated. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.

Class variables − Class variables are variables declared within a class, outside any method, with the static keyword.
object in Java
An object contains both the data and the function, which operates on the data. An entity that has state and behavior is known as an object e.g., chair, bike, marker, pen, table, car, etc. It can be physical or logical (tangible and intangible).

The example of an intangible object is the banking system. An object has three characteristics:

State: represents the data (value) of an object.

Behaviour: represents the behavior (functionality) of an object such as deposit, withdraw, etc.

Identity: An object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user. However, it is used internally by the JVM to identify each object uniquely.

Example - chair, bike, marker, pen, table, car, etc.