Features of Java

    We can call Java a revolutionary technology because it has brought in a fundamental shift in how we develop and use programs. Java is not only reliable, portable, and distributed but also simple, compact, and interactive.

    The following features aptly describe the full potential of the language. These features have made Java the first application language of the World Wide Web.

    Features of Java

    The  general features of Java are:

    1. Compiled and Interpreted

    A programming language can either be compiled or interpreted. But Java can be both compiled and interpreted. This striking feature makes the Java programming language more flexible. The Java compiler (javac) first converts the source code into an intermediate code called bytecode.

    Later, Java Virtual Machine (JVM) translates the compiled bytecode, which is platform-independent, into machine code.

    2. Platform-Independent and Portable

    Portability is the most significant contribution of Java. The programs can be easily moved from one computer system to another. Hence, Java has become the most popular language for programming on the internet, which interconnects different kinds of systems worldwide.

    Java ensures portability in two ways:

    • Bytecode instructions generated by the Java compiler can be implemented on any machine.
    • The size of primitive data types is machine-independent.

    3. Object-Oriented

    Almost everything in Java is an object. All program code and data reside within the objects and classes. OOP concepts involve in Java are as follows:

    • Object and Classes: Objects are basic runtime entities in an object-oriented system. Objects contain code and data to manipulate the data. This entire set of data and code can be thought of user-defined data type using the concept of class. A class is thus a collection of objects of similar type.
    • Abstraction and Encapsulation: Enclosing data and methods into a single unit is known as encapsulation. It means only the methods that are wrapped inside a class can access the data in the class. Thus, tasks are performed without knowing the internal implementation. Abstraction refers to representing essential features without including background details.
    • Inheritance: The process by which objects of one class derive the properties of objects of another class.
    • Polymorphism: This means the ability to take many forms. It plays an important role in allowing objects having different internal structures to share the same external interface. Polymorphism is used in implementing inheritance.

    4. Robust and Secure

    Java is a robust language because it can handle runtime errors, supports exception handling , avoids explicit pointers, and supports automatic garbage collection. As the source code is checked twice, it becomes easier to eliminate errors in Java code at runtime and compile time. In addition, when compared to C and C++ , Java is more secure.

    C and C++ manage their application memory and protect data using pointer values. Unfortunately, malicious hackers or attackers can use pointers to access memory and steal confidential data. On the other hand, Java does not support explicit pointers and uses a data management system and its own memory to block such unauthorized access to data.

    5. Distributed

    Java has the ability to access both data and programs. Java applications can open and access remote objects on the Internet, thus enabling multiple programmers at remote locations to collaborate and work together on a single project.

    6. Simple and Familiar

    Java is a simple language, as it does not involve any intricate functionalities like C or C++. It eliminates various ambiguous concepts from C and C++, like multiple inheritance, goto statements, operator overloading , explicit pointers, and preprocessors.

    Also, the basic programming concepts of Java are analogous to C and C++. Therefore, having good knowledge of C and C++ would make it easier for you to learn Java.

    7. Multithreaded and Interactive

    Java supports multithreading, i.e., executing multiple tasks or running different portions of the same program simultaneously. It divides the source code into smaller units and runs multiple units parallelly.

    In addition, Java is interactive because it supports Graphical User Interface (GUI) and Character User Interface (CUI) programs. It significantly enhances the interactive performance of graphical applications.

    8. High Performance

    Intermediate bytecode offers high performance in Java. Java architecture is designed to reduce overheads during runtime. Further, the incorporation of multithreading enhances the overall execution speed.

    9. Dynamic and Extensible

    Java is capable of dynamically linking in new class libraries, methods, and objects. Java programs support functions written in other languages, such as C and C++. These functions are known as native methods that are dynamically linked at runtime.

    10. Scalability and Performance

    Java ensures performance by improving startup time and reducing the amount of runtime used in the runtime environment.

    11. Monitoring and Manageability

    Java supports a number of APIs, such as JVM Monitoring and Management API to track the information at the application level, Java Management Extension(JMX), etc. It also provides controls such as jconsole, jps etc to make use of monitoring and management facilities.

    12. Desktop Client

    Java provides Swing, used for developing graphics applications that require OpenGL hardware acceleration.

    Miscellaneous Features

    The following are the miscellaneous features:

    • Core XML Support : Java contains some special packages for the interface, to instantiate Simple API for XML and Document Object Model (DOM) parses to parse an XML document, transform the content of the XML document and validate an XML document against the schema.
    • Supplementary Character Support : Java adds the 32-bit supplementary character support.
    • JDBC Rowset : Java supports JDBC Rowset to send data in tabular form between the remote components of distributed enterprise applications.

    Features of Java 12

    1. Switch Expression (JEP 325)

    Beta switch expression will improve coding by extending the switch statement, enabling its use as either a statement or an expression. This will help simplify the code and also introduce the use of pattern matching in a switch.

    Java programming is being enhanced to use pattern matching to resolve several issues, including the default control flow behavior of switch blocks, default scoping switch blocks, and switch working only as a statement.

    Java 11

    int numberOfLetters
    switch(fruit)
    {
    case PEAR:
    numberOfLetters = 4;
    break;
    case APPLE:
    case GRAPE:
    case MANGO:
    numberOfLetters = 5;
    break;
    case ORANGE:
    case PAPAYA:
    numberOfLetters = 6;
    break;
    default: 
    throw new IllegalStateException("Wut" + fruit);
    }

    Java 12

    int numberOfLetters = switch(fruit)
    {
    case PEAR -> 4;
    case APPLE, MANGO, GRAPE -> 5;
    case ORANGE,PAPAYA -> 6;
    }

    2. Default CDS Archives (JEP 341)

    Improved JDK build process by generating a class data-sharing (CDS) archive with the help of the default class list on the 64-bit platform. Thus this feature has a goal to:

    • Improve startup time.
    • Get rid of the need to run X-share: dump to benefit from the CDS.

    3. A Low-Pause-Time Garbage Collector

    Garbage collector algorithm Shenandoah aims to guarantee low response times by reducing evacuation work simultaneously with the running Java threads.

    4. JVM Constants API

    Introduces an API modeling the key class file and run-time artifacts, such as a constant pool.

    5. Abortable Mixed Collections for G1

    This feature makes the Garbage First (G1) garbage collector abort the GC process more efficiently by splitting the mixed collection set into mandatory and optional parts.

    6. Promptly Return Unused Committed Memory from G1

    The main goal of this feature is to improve the G1 garbage collector to return Java heap memory to the OS when inactive immediately. This is achieved by periodically generating or continuing a concurrent cycle to check the complete Java heap usage.