Introduction to Java Programming

Introduction to Java Programming

Introduction to Java Programming


Introduction to Java Programming

Introduction to Programming

A program is a set of instructions that convey to the computer to do some specific operation.

Basic of Programming

       As we communicate with some human language like English, Hindi, Urdu, German etc has its own set of grammar rules. All language has some short of Grammar and syntax.
       In the same way the Computer has some of its own grammar and rules. There are certain basic program code elements which are common for all the programming languages
Most important elements for programming languages are:
       Its Environment
       Some Reserve words or Keywords
       Data Types
       Variables
       Various kind of operators
       Input and Output Operations
       Conditional such as if.. else
       Loops( for, while, do..while)
       Numbers, Characters and Arrays
       Method or Functions

Procedure Oriented Programming

It is a programming model which is derived from structured programming, based upon the concept of calling procedure(the other name of Procedures are routines, subroutines or functions, simply consist of a series of computational steps to be carried out. Example : C, Fortran, Pascal etc

Drawbacks Procedure Oriented Programming:

       Emphasis on function
       Inability to reuse code throughout the program
       Uses top-down approach
       Adding new data and function is not easy
       Unsecure

Object-Oriented Programming

Object-oriented programming (OOP) is a new way of organizing around objects which represent as an instance of a class and it revolves around Abstraction, Encapsulation, Inheritance and Polymorphism.

What are the Basic Features of java?

  • Java is an object-oriented language.
  • Java is Easy to write and more readable and eye-catching.
  • Java program cannot harm other systems thus making it secure.
  • Java programs can be run on any platform (Linux, Window, Mac)
  • Java program both compiled and interpreted
  • Java provides integrated support for multithreaded programming. It can handle many tasks simultaneously.
  • Java was designed with a distributed environment.
  • Java has a strong memory allocation and automatic garbage collection mechanism.
  • Java uses 16-bit Unicode, instead of 8-bit ASCII code.

       

What are the advantages of OOP?

       Easy to relate to the real world.
       Data is protected from misuse.
       All data is hidden only the method is visible.
       We can reuse the code with the help of the Inheritance concept.
        Secured
       Easy to maintain

What are the Basic components of OOP?

  • Class—It is a blueprint of an object.
  • Object—An instance of a class or It is a template of a class.
  • Encapsulation—The wrapping up of data and method into a single unit called Encapsulation.
  • Abstraction—It is the act of representing essential features without including the background details.
  • Polymorphism -- polymorphism refers to a programming language's ability to process objects differently depending on their data type or class.
  • Inheritance -- Inheritance is the process by which objects of one class acquire the properties of objects of another class.

 
Java Compiler-Java Byte Code-java interpreter
Java Compiler-Java Byte Code-java interpreter
Java Virtual Machine Architecture
Java Virtual Machine Architecture

To create a java code an editor such as notepad, text pad or an IDE like eclipse, Bluej can be used.
 Sample Java Program:


     public class MyFirst
    {
           public  static void main(String[] args)
          {
                   System.out.println(“Welcome to Java”);
           }//End of main
    }//End of MyFirst Class

Output: Welcome to Java

In the above program, the class MyFirst has public access and hence declared public.
‘class’ is the keyword used to create a class.
For running standalone programs ‘main’ method is needed which has a signature similar to the one defined in the above program.
‘Main’ method takes an array of strings as an argument. The name of the array can be anything.
To display the output, pass the string as an argument to the method System.out.println

More Post you may be interested

History of java