Java Basics – Overview, Features, JVM and more

Overview

The famous Java programming language was developed by Sun microsystems which were then initiated by James Gosling. It was released in the year 1995 and it acted as the main component of the Sun microsystem’s Java platform. Java SE 8 is the latest release of Java’s standard edition. As Java advanced and gained widespread popularity around the globe, many configurations were built then in order to suit different types of platforms.

There are many examples such as J2ME for mobile applications and J2EE for enterprise applications. The two versions of this language were renamed as Java EE, Java ME, and Java SE respectively. It is a write-once and runs anywhere type of language. The language Java is preferred by many people around the world because of its large number of features such as it is object-oriented, platform-independent, simple, secure, architecture-neutral, portable, robust, multithreaded, integrated, high-performance, distributed, and dynamic.

Features

In the previous section, we talked about what is Java and what are its different features. Now, in this section, we will discuss in detail those features. The features are as follows –

Object-oriented

Java is a programming language in which everything is an object. It can be very easily extended because it is based on the model of the object.

Platform independent

When we compile Java, it does not get compiled into a platform-specific machine. This happens in other programming languages such as C and C++. However, Java is rather into platform-independent bytecode. The bytecode is generally distributed over the web and then it is interpreted by the JVM on which platform it is running on.

Simple

Java is easy to learn. Even if you understand all the basic concepts of OOP Java, it will be very easy to master this language.

Secure

Java has a unique security feature that allows us to develop virus-free and tamper-free systems. Its authentication techniques are completely based on public-key encryption.

Architecture neutral 

An architecture-neutral object file format is generated by the Java compiler and that makes the compiled code execute on different processes and that too with the presence of the Java runtime system.

Portable

Since Java is architecture-neutral and it has no implementation-dependent aspects of any specification, it makes it portable. Java compiler is written in ANSI C. It has a clean portability boundary that is a POSIX subset.

Robust

Java language mainly emphasizes the compile-time error checking as well as the runtime checking as it makes an effort to eliminate all the errors.

Multithreaded

Java is multithreaded which means that it is possible to write programs that can easily perform management tasks at once. It enables the developers to create interactive applications that run smoothly.

Interpreted

Java’s byte code translates to native machine instructions. It is not stored anywhere. Its development processes are quick as well as analytical as the linking is a lightweight and incremental process.

High performance

Java enables high performance because it uses just in time compilers.

Distributed

Java is specifically designed for the distributed environment of the internet.

Dynamic

Java is more dynamic than other languages such as C and C++. It is designed in a way that it adapts to a changing environment. Its programs can easily carry a large amount of runtime information. That information can be used to verify and then resolve access to several objects at the runtime.

Introduction to JVM

JVM stands for Java virtual machine and it has many different implementations that are there to the specs. Many organizations such as Oracle and IBM have their own JVM. JVM is a kind of a virtual machine or an abstract computer that has its own ISA, memory, heap, stack, etc. It runs on the host operating system and then it places its demands for the resources to it. The different operations that are defined inside the specs are as follows –

  • Public design and private implementation
  • The class file format
  • Class libraries
  • Data types
  • Instruction set summary
  • Primitive types and values
  • Exceptions
  • Reference types and values
  • Special methods
  • Runtime data areas
  • Floating-point arithmetic
  • Frames
  • Representation of objects

My first Java Program

For creating a Java program you need to install the Java development kit, set the path of the bin directory, create the Java program, and then compile and run it. The latest create our first Java program. Go through the following code to create it.

Class JavaFirst{

public static void main(String args[]){

System.out.println(“Hello Java”);

}

}

Output: Hello Java

Variables in Java

A variable in Java is a container that holds a value while your Java program is being executed. The variable is assigned with a certain data type. Variable is basically the name of a memory location full stop there are three kinds of a variable in this programming language that is the local, instance, and static variables.

Local variable – My local variable is a kind of variable that is declared inside the body of the method. We can use it only in that method and the other methods in the class are not even aware that this variable exists.

Instance variable – This kind of variable is declared inside the class but outside the method’s body. It cannot be declared as static. It is called so because its value is instance specific and it cannot be shared among other instances.

Static variable – it is declared as static and it cannot be local. We can create a single copy of this variable and then can share it among other instances of the class.

Data types and Identifiers

Data types in java are classified into two categories that are the primitive data types and non-primitive data types.

  1. Primitive Data Types – There are 8 kinds of primitive data types namely byte, short, int, long, float, double, char, and Boolean. Once we declare them, we can’t change them. However, its value can change.
  2. Non-primitive Data Types – A non-primitive data type is also known as a reference data type and it is used to refer to an object. It is specifically declared and it can never be changed. The objects can be an instance of an entity or any class.

Identifiers – The components of Java require names. We use the name for classes, interfaces, variables, and methods and they are known as identifiers.

Leave a Comment