Our Team

Deepak Patnaik

2029124

Mimansha Aryan

2029173

Sagnik Chakravarty

2029141

Priya Aditi

2029022

Priyanshu Modi

2029106

Introduction to java

  • BRIEF HISTORY OF JAVA
  • -Java was developed by a group of programmers led by James Arthur Gosling

    - He was working for the company Sun Micro Systems

    - 1990 : Started the project.

    - 1991 : Released first version called "oak".

    - 1995 : Completed the programming language and renamed it to "Java".

    - 2010 : Oracle Corporation acquired sun Microsystem .


  • ADVANTAGES OF JAVA
  • - JAVA is an Object Oriented Programming Language.

          Object-oriented programming, is a problem-solving method in which the software solution
          reflects objects in the real world.

    - JAVA programs are platform independent.

          JAVA programs are platform independent means that the same java program can be executed on
          devices with different processors or with different operating systems without any modification.
          This feature is also referred to as WORA (Write Once Run Anywhere).


  • TYPES OF JAVA PROGRAMS
  • Two types of java programs are java application and java applet

    - A java application is a general java program meant to be executed on a stand-alone computer.
       e.g.: a program to find the sum of two numbers.

    - A Java applet is a special kind of Java program that a web browser enabled with Java technology
       can download from the internet and execute. Java Applet can also be executed by a special software
       called applet viewer.

JDK, JRE & JVM

  • JDK
  • JDK is abbreviation for Java Development Kit which includes all the tools, executable and binaries required to compile, debug and execute a
    Java Program.JDK is platform dependent i.e there is separate installers for Windows, Mac, and Unix systems.JDK includes both JVM and JRE and
    is entirely responsible for code execution. It is the version of JDK which represent version of Java.

  • JRE
  • JRE is Java runtime environment which is the implementation of JVM i.e the specifications which are defined in JVM are implemented
    and creates corresponding environment for the execution of code.JRE comprises mainly java binaries and other classes to execute the
    program alike of JVM it physically exists. Along with Java binaries JRE also consist of various technologies of deployment, user interfaces
    to interact with code executed, some base libraries for different functionalities and language and util based libraries.

  • JVM
  • JVM is the abbreviation for Java virtual machine which is basically specification that provides a runtime environment
    in which Java byte code can be executed i.e it is something which is abstract and its implementation is independent to
    choose the algorithm and has been provided by Sun and other companies. It is JVM which is responsible for converting
    Byte code to the machine specific code. It can also run those programs which are written in other languages and compiled
    to Java bytecode.The JVM performs the mentioned tasks: Loads code, Verifies code, Executes code, Provides runtime environment.

Differences
Sr no. Key JDK JRE JVM
1 Prime functionality JDK is primarily used for code execution and has prime functionality of development. On the other hand JRE is majorly responsible for creating environment for code execution. JVM on ther hand specifies all the implementations and responsible to provide these implementations to JRE.
2 Platform Independence JDK is platform dependent i.e for different platforms different JDK is required. Like of JDK, JRE is also platform dependent. JVM is platform independent.
3 Tools As JDK is responsiblefor prime development so it contains tools for developing, debugging and monitoring java application. JRE does not contain such tools such as compiler or debugger etc. Rather it contains class libraries and other supporting files that JVM requires to run the program. JVM does not include software development tools.
4 Implementation JDK = Java Runtime Environment (JRE) + Development tools. JRE = Java Virtual Machine (JVM) + Libraries to run the application. JVM = Only Runtime environment for executing the java byte code.

Characteristics of Java

  • Object Oriented
  •    In Java, everything is an Object. Java can be easily extended since it is based on the Object model.


  • Platform Independent
  •    Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine,
       rather into platform-independent byte code. This byte code is distributed over the web and interpreted by the Virtual Machine (JVM) on whichever platform it is being run on.


  • Simple
  •    Java is designed to be easy to learn. If you understand the basic concept of OOP Java, it would be easy to master.


  • Portable
  •    Being architecture-neutral and having no implementation dependent aspects of the specification makes Java portable.
       The compiler in Java is written in ANSI C with a clean portability boundary, which is a POSIX subset.


  • High Performance
  •    With the use of Just-In-Time compilers, Java enables high performance.


  • Distributed
  •    Java is designed for the distributed environment of the internet.


  • Dynamic
  •    Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment.
       Java programs can carry an extensive amount of run-time information that can be used to verify and resolve accesses to objects at run-time.

OOP Principles

Java defines OOP concepts as follows:

  • Abstraction

- Using simple things to represent complexity. We all know how to turn the TV on, &nbut we don’t need to know
   how it works in order to enjoy it. In Java, abstraction means simple things like objects, classes and variables
   represent more complex underlying code and data. This is important because it lets you avoid repeating the same work
   multiple times.


  • Encapsulation

- The practice of keeping fields within a class private, then providing access to those fields via public methods.
   Encapsulation is a protective barrier that keeps the data and code safe within the class itself. We can then reuse
   objects like code components or variables without allowing open access to the data system-wide.


  • Polymorphism

- Allows programmers to use the same word in Java to mean different things in different contexts. One form of
   polymorphism is method overloading. That’s when the code itself implies different meanings. The other form is
   method overriding. That’s when the values of the supplied variables imply different meanings. Let’s delve a little further.


  • Inheritance

- A special feature of Object-Oriented Programming in Java, Inheritance lets programmers create new classes that share
   some of the attributes of existing classes. Using Inheritance lets us build on previous work without reinventing the wheel.

A Simple Program

Program to add two numbers

 import java.util.Scanner;
 public class AddTwoNumbers
{
   public static void main(String[] args)
  {
      int num1, num2, sum;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter First Number: ");
      num1 = sc.nextInt();

      System.out.println("Enter Second Number: ");
      num2 = sc.nextInt();

      sc.close();
      sum = num1 + num2;
      System.out.println("Sum of these numbers: "+sum);
    }
}

Compiling & Execution