Java Programming – Introduction | History | Features | C++ vs Java

In this programming tutorial we will take an introduction of Core Java Programming Language. Java is a programming language and a platform. Java is a high level, robust, secured and object-oriented programming language.
Platform: Any hardware or software environment in which a program runs, is known as a platform. Since Java has its own runtime environment (JRE), it is called platform.

History –

Java programming language was originally developed by Sun Microsystems(currently acquired by Oracle Corporation) which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems Java platform. Current Stable release: Java SE 9.0.4

Features of Java –

features of java programming language

  • Simple –
    • Java is very easy to learn and its syntax is simple, clean and easy to understand. If you come from C++ programming background, it will be even more easier to understand as some complex concepts like pointers, operator overloading etc are elminated in Java.
  • Secured – 
    • Java ensures high security since it runs inside the JVM (Java Virtual Machine)
      • Java is Secured because –
      • No explicit pointer
      • Java Programs run inside Java Virtual Machine
      • Classloader: Classloader in Java is a part of the Java Runtime Environment(JRE) which is used to dynamically load Java classes into the Java Virtual Machine.
      • Bytecode Verifier: It checks the code fragments for illegal code that can violate access right to objects.
      • Security Manager: It determines what resources a class can access such as reading and writing to the local disk.

  • Robust – 
    • Robust simply means strong. Java is robust because:
      • It uses strong memory management.
      • There are lack of pointers that avoids security problem.
      • There is automatic garbage collection in java.
      • There is exception handling and type checking mechanism in java
  • Object-oriented – 
    • Java is Object-oriented programming language. Everything in Java is an object.
    • Basic concepts of OOPs are:
      • Object
      • Class
      • Inheritance
      • Polymorphism
      • Abstraction
      • Encapsulation
  • Platform Independent – 
    • Java is a write once, run anywhere language. Java code can be run on multiple platforms e.g. Windows, Linux, Sun Solaris, Mac/OS etc. Java code is compiled by the compiler and converted into bytecode. This bytecode is a platform-independent code because it can be run on multiple platforms i.e. Write Once and Run Anywhere(WORA).

  • Architecture-neutral – 
    • Java is architecture neutral because there is no implementation dependent features e.g. size of primitive types is fixed.
    • In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4 bytes of memory for 64-bit architecture. But in java, it occupies 4 bytes of memory for both 32 and 64 bit architectures.
  • Portable – 
    • Java is portable because it facilitates you to carry the java bytecode to any platform.
  • High-performance – 
    • Java is faster than traditional interpretation since bytecode is “close” to native code.
    • Also it is supported by JIT compiler (JUST-IN-TIME Compiler) to speed up the execution process
  • Distributed – 
    • Java is distributed because it facilitates us to create distributed applications in java. RMI and EJB are used for creating distributed applications.
  • Multi-threaded – 
    • A thread is like a separate program, executing concurrently. We can write Java programs that deal with many tasks at once by defining multiple threads.
    • The main advantage of multi-threading is that it doesn’t occupy memory for each thread. It shares a common memory area.
    • Threads are important for multi-media, Web applications etc.
  • Interpreted – 
    • Java is compiled as well as interpretted programming language. It is first compiled to bytecode and then interpretted line by line into machine code.
Types of Java Applications

Depending upon where Java id used they are usually categorized into 4 types –

  • Standalone Application – 
    • Standalone applications are also known as desktop applications or window-based applications. These are traditional software that we need to install on every machine. E.g. Media player, antivirus etc.
  • Web Application – 
    • An application that runs on the server side and creates dynamic page, is called web application. Java programming language can be used to make Dynamic web applications that can be scalable, robust and secure. E.g. Payment Gateways, E-Commerce websites, blogging websites etc.
  • Enterprise Application – 
    • An application that is distributed in nature, such as banking applications etc. is called enterprise application. It has the advantage of high level security, load balancing and clustering. In java, EJB is used for creating enterprise applications.
  • Mobile Application –
    • An application that is created for mobile devices. Currently Android and Java ME are used for creating mobile applications.
Java Platforms / Editions

There are 4 platforms or editions of Java:

  1. Java SE (Java Standard Edition)
    • It is a java programming platform. It includes Java programming APIs such as java.lang, java.io, java.net, java.util, java.sql, java.math etc. It includes core topics like OOPs, String, Regex, Exception, Inner classes, Multithreading, I/O Stream, Networking, AWT, Swing, Reflection, Collection etc.
  2. Java EE (Java Enterprise Edition)
    • It is an enterprise platform which is mainly used to develop web and enterprise applications. It is built on the top of Java SE platform. It includes topics like Servlet, JSP, Web Services, EJB, JPA etc.
  3. Java ME (Java Micro Edition)
    • It is a micro platform which is mainly used to develop mobile applications.
  4. JavaFx
    • It is used to develop rich internet applications. It uses light-weight user interface API.
Where is Java Used ?

Java programming is a very diverse language and is used in a variety of different applications, softwares, projects etc. Following are some types of Applications –

  • Desktop Applications
  • Web Applications
  • Enterprise Applications
  • Mobile Applications
  • Embedded System
  • Smart Card
  • Robotics
  • Games etc.
C++ Programming vs Java Programming

Comparison Index

C++

Java

Platform-independentC++ is platform-dependent.Java is platform-independent.
Mainly used forC++ is mainly used for system programming.Java is mainly used for application programming. It is widely used in window, web-based, enterprise and mobile applications.
GotoC++ supports goto statement.Java doesn’t support goto statement.
Multiple inheritanceC++ supports multiple inheritance.Java doesn’t support multiple inheritance through class. It can be achieved by interfaces in java.
Operator OverloadingC++ supports operator overloading.Java doesn’t support operator overloading.
PointersC++ supports pointers. You can write pointer program in C++.Java supports pointer internally. But you can’t write the pointer program in java.
Compiler and InterpreterC++ uses compiler only.Java uses compiler and interpreter both.
Call by Value and Call by referenceC++ supports both call by value and call by reference.Java supports call by value only. There is no call by reference in java.
Structure and UnionC++ supports structures and unions.Java doesn’t support structures and unions.
Thread SupportC++ doesn’t have built-in support for threads.Java has built-in thread support.
Virtual KeywordC++ supports virtual keyword so that we can decide whether or not override a function.Java has no virtual keyword. We can override all non-static methods by default. In other words, non-static methods are virtual by default.
Watch it on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *