Java Introduction

What are the features in Java?

  • Java is a high-level programming language originally developed by Sun Microsystems and released in 1995.
  • Java is platform independent language and runs on a variety of platforms, such as Windows, Mac OS, and UNIX.
  • Object Oriented - Java supports the object oriented programming language and everything is object and features developed in java which can be easily extended.
  • Platform Independent − Java is compiled into platform independent byte code. This byte code is distributed over the web and interpreted by the Java Virtual Machine (JVM) on whichever platform it is being run on. (Write once, run anywhere)
  • Portable − Architecture-neutral and having no implementation dependent aspects of the specification makes Java portable. carry and run the java bytecode in any platform.
  • Robust − Eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.
  • Multithreaded − It is possible to write programs that can perform multiple tasks simultaneously.
  • Interpreted − Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is an incremental and light-weight process.
  • High Performance − Java uses Just-In-Time compilers and provides high performance
  • Distributed − Designed for the distributed environment of the internet.
  • Dynamic − Java is considered to be more dynamic and programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.
  • Secure - Execution of every java program is under the control of the JVM. JVM can contain the program and prevent it from generating side effects outside of the system.

How to install Java on Linux environment?

Java installation:Download Java SE Development Kit 8 RPM from the link.
Install the downloaded RPM by running linux command
# Change current user to root user.
$ su -

# installs RPM in fedora, here /home/user dir is the rpm file downloaded location.
# rpm -Uvh /home/user/jdk-8u144-linux-x64.rpm  
JDK installer for different environments like windows, Mac OS and Solaris can be downloaded in link

Java Program Example:

// Sample Java code
public class Example {

   public static void main(String []args) {

How to compile and run java program?

c:\Java_code> javac
C:\Java_code> java Example 

Javac compiler translates file into Example.class file that contains the bytecode version of the program. Example.class file cannot be directly executed.

To execute the Example.class, must use the java interpreter (java command). Java command interprets and executes the compiled java code.

What is Java history?

Originally developed by James Gosling at Sun Microsystems(which has since been acquired by Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform

What does Java compiler?

Create the java program in .java file and then compile the program using javac command.
Compiler checks program against the java language syntax rules, then converts into bytecode in .class files. Bytecode is a set of instructions targeted to run on a Java virtual machine (JVM).
Translating java program into bytecode makes it mush easier to run a program in a wide varity of environments.
Java compiler writes out instruction(bytecode) is suitable for CPU processor.

What is Java Platform?

A platform is the hardware or software environment in which a program runs. Java platform is a software-only platform that runs on top of other hardware-based platforms.
Two components:
  • Java Virtual Machine (JVM): This is Virtual Machine, base for the Java platform and is ported onto various hardware-based platforms. At runtime, JVM interprets .class files and executes the program's instructions on the native hardware platform where JVM runs.
    JVM is a software written specific to any particular platform. only JVM needs to be implemented for each platform
  • Java Application Programming Interface (API): API is a large collection of predefined software components and grouped into libraries of classes and interfaces. this libraries are also called packages.

What is Garbage Collector in java?

Java supports implicit memory management and it is one of the important features in java.
Java code creates an object instance at runtime, the JVM automatically allocates memory for that object from the heap. Java garbage collector runs in the background, keeping track of which objects are no longer needs. and cleans memory from objects which will not be needed.

What is Java Development Kit?

JDK contains compiler, other tools and complete class library of prebuilt utilities that is used for most common application development tasks.

What is Java Runtime Environment?

JRE contains JVM, libraries, and components that are required to run java programs.
JRE is available for multiple platforms.

What is just-in-time compiler?

Compilation is done during execution of a program at run time rather than prior to execution.
Component of the JRE and improves the performance of Java code at run time.
JIT compiler is enabled by default, and is activated when a Java method is called and compiles the bytecodes of that method into native machine code.
Java Programming Language Examples

GCD and Rational Number Java Program

Java Queue Program using exception

Java Stack Program using exception

Addition of three integers java program

Biggest of three integers java program

Fibonacci numbers java program

Arithmetic Operations Menu java program

Second Smallest Element In Array Java Program

Transpose Of A Matrix Java Program

Java Program to Display triangle of stars (*)

Java Programming Prints Product Tables

Java Program to Display triangle of numbers

Java Programming Gets Current Date

Java Programming Finds Character Vowel or Consonent

Java Programming HCF and LCM Computation

Java Programming Sum of Command Line Integer Arguments

Java Programming Multiplication of Command Line Integer Arguments

Java Programming Multiplication of Command Line Floating Point Numeric Arguments

Java Programming String Contains or Not

Java Programming Gets Grade Description using Switch

Java Programming CSV File Reader

Java Programming Character Frequency Count in String using for each

Java Programming Finds Min from Integer Array by Passing Array to Method

Java Programming Linear Search

Java Programming Binary Search

Java Programming Ternary Search

Java Programming Generates Range of Numbers

Java Programming Generates Range of Characters

Java Programming Computes Square Root Value

Java Programming Checks Number is Positive or Negative

Java Programming Checks Number is Odd or Even

Java Programming Computes Plot Area

Java Programming Convert Number of Days into Years

Java Programming Checks a Year is Leap Year, Century Year or Not

Java Programming Checks a Character is Digit, Letter or neither digit nor letter

Java Programming Checks a Number is Palindrome or not

Java Programming Sum of Two Matrix

Java Programming Power Computation

Java Programming Checks Number is an Armstrong Number or not

Java Programming Temperature Unit Conversions

Java Programming Generates Random Numbers in Specified Range

Java Programming Computes Sum of Digits and Product of Digits

Java Programming Computes Reverse Number

Java Programming Computes Factorial Value

Java Programming Checks Prime Number or not

Java Programming Computes Harmonic Series

Java Programming Generates Floyd's Triangle

Java Programming Reverses String

Java Programming Checks Palindrome String or not

Java Programming Opens Notepad

Java Programming Searches String using RegEx Pattern

Java Programming Searches Word in String

Java Programming Gets System Environment Variables

Java Programming Gets IP Address of Server Name

Java Programming Arrays Sort and Reverse using sort method

Java Programming Bubble Sorting

Java Programming Selection Sorting

Java Programming Insertion Sorting

Java Programming Merge Sorting

Java Programming Quick Sorting

Java Programming Counting Sort

Java Programming Radix Sorting

Java Programming Sorting Array of Strings

Java Programming String Characters Sorting

Java Programming Sum of First N Numbers

Java Programming Product of First N Numbers

Privacy Policy  |  Copyright@2017 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter