Java Introduction - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Java Introduction - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Friday, November 23, 2018

Java Introduction

Java Introduction


Java programming language


INTRODUCTION  TO JAVA PROGRAMMING LANGUAGE


 Java is a programming language created by James Gosling from Sun Microsystems (Sun) in 1991. The target of Java is to write a program once and then run this program on multiple operating systems. 

JAVA is a Programming Language and a Computing Platform for Application Development. JAVA Platform is a Collection of Programs that help to Develop and run Programs written in the JAVA Programming LanguageJAVA Platform includes an execution engine, a compiler, and a set of Libraries.

Java programming Language stepped into the world and got dominant status. In this unit you will learn the advantages and strength of Java, and what actually makes Java powerful and popular.

Objectives

After going through this unit, you should be able to:
  • describe the strength of Java language;
  • explain Java virtual machine concepts;
  • differentiate between Java applet and Java application;
  • write simple programs in Java;
  • compile and execute Java applets and application programs;
  • describe the data types in Java, and
declare and initialize of variables in the programs. 

OBJECT ORIENTED PROGRAMMING


object oriented programming (oops)


Java is a true object-oriented Language, which provides a platform to develop an effective and efficient application and program real life complexities.

Object Oriented Programming is a method of implementation in which programs are organized as cooperative collection of objects, each of which represents an instance of a class, and whose classes are all members of a hierarchy of classes united via inheritance relationships.

Four principles of Object Oriented Programming are

Abstraction.
Encapsulation.
Inheritance.
Polymorphism.
Abstraction
         Abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer.
Encapsulation

        Encapsulation is the process of compartmentalizing the elements of an abstraction that constitute its structure and behavior ; encapsulation serves to separate the contractual interface of an abstraction and its implementation.
       * Hides the implementation details of a class.
       * Forces the user to use an interface to access data
       * Makes the code more maintainable.
Inheritance
        Inheritance is the process by which one object acquires the properties of another object.
Polymorphism
        Polymorphism is the existence of the classes or methods in different forms or single name denoting different implementations.

JAVA IS MULTITHREADED


Java multithread


Java is inherently multi-threaded, for example Garbage collection subsystem runs as a low-priority thread. A single Java program can have many different threads executing independently and continuously, for example different Java applets on the same web page can run together with getting equal time from the processor.

One of the powerful aspects of the Java language is that it allows multiple threads of execution to run concurrently within the same program A single Java program can have many different threads executing independently and continuously. Multiple Java applets can run on the browser at the same time sharing the CPU time.

JAVA IS SECURE


security measures for Java
Java  secure image

Java was designed to allow secure execution of code across network. To make Java secure many of the features of C and C++ were eliminated. Java does not use Pointers. Java programs cannot access arbitrary addresses in memory.
Java is intended to work in networked and distributed environments by providing security. All the references to memory are symbolic references, meaning that the user is not aware where in the memory program is present, it totally depends on the JVM and machine on which the program is running. 
Each applets is loaded on its own memory space, which avoids the information interchange between applets.

JAVA APPLICATIONS

Java application

Java has evolved from a simple language providing interactive dynamic content for web pages to a predominant enterprise-enabled programming language suitable for developing significant and critical applications. 

Today, It is used for many types of applications including Web based applications, Financial applications, Gaming applications, embedded systems, Distributed enterprise applications, mobile applications, Image processors, desktop applications and many more. This site outlines the building blocks of java by stating few java examples along with some java tutorials.                                 

Java Operator

Operators are special symbols (characters) that carry out operations on operands (variables and values). For example, + is an operator that performs addition.

Assignment Operator

The basic assignment operator  "="  is used to assign value to the variables. Forexample A=B; in which we assign value of B to A.

Java Arithmetic Operators
OperatorMeaning
+Addition (also used for string concatenation)
-Subtraction Operator
*Multiplication Operator
/Division Operator
%Remainder Operator

Unary Operators

Unary operator performs operation on only one operand.
OperatorMeaning
+Unary plus (not necessary to use since numbers are positive without using it)
-Unary minus; inverts the sign of an expression
++Increment operator; increments value by 1
--decrement operator; decrements value by 1
!Logical complement operator; inverts the value of a boolean

Equality and Relational Operators

The equality and relational operators determines the relationship between two operands. It checks if an operand is greater than, less than, equal to, not equal to and so on. Depending on the relationship, it results to either true or false.
Java Equality and Relational Operators
OperatorDescriptionExample
==equal to5 == 3 is evaluated to false
!=not equal to5 != 3 is evaluated to true
>greater than5 > 3 is evaluated to true
<less than5 < 3 is evaluated to false
>=greater than or equal to5 >= 5 is evaluated to true
<=less then or equal to5 <= 5 is evaluated to true

Logical Operators

The logical operators || (conditional-OR) and && (conditional-AND) operates on boolean expressions. Here's how they work.
Java Logical Operators
OperatorDescriptionExample
||conditional-OR; true if either of the boolean expression is truefalse || true is evaluated to true
&&conditional-AND; true if all boolean expressions are truefalse && true is evaluated to false

Bitwise Operator

To perform bitwise and bit shift operators in Java, these operators are used.

Java Bitwise and Bit Shift Operators
OperatorDescription
~Bitwise Complement
<<Left Shift
>>Right Shift
>>>Unsigned Right Shift
&Bitwise AND
^Bitwise exclusive OR
|Bitwise inclusive OR

Hello World in Java

class hello_world{
 public static void main(String args[]){
  System.out.println("Hello World");
 }
}


How To Run? Open Terminal And create a file hello_world.java

Then

Run the Command


javac hello_world.java
java hello_world 

No comments:

Post a Comment

Post Top Ad