Java:
Java is a OOP originally developed by sun microsystems which was initieted by Jems Gosling and released in 1995. It is owned by oracle and more than 3 billion devices run java.
Java is a High Level, Object-Oriented, Secure Programming Language, High Performance, Robust, Platform Independent, Multi thread, Portable Programming Language. It own Java Runtime Environment (JRE) and Application Programming Interface (API).
Use of Java:
Java is used for -
- Mobile applications (specially android apps)
- Desktop applications
- Web applications
- Web server and application servers
- Games
- Data base connection.
Advantage of Java:
- Java works on different platforms (Ma-windows, Mac, Linux, etc.)
- It is one of the most popular programming language in the world.
- Simple and easy to learn.
- Open source and free.
- It is a fast, secure, powerful programming language.
- Java is a OOP which gives a clear structure to programs and allow code to be reused, lowering development cost.
- Huge community support.
- As Java is close to C and C++, it makes easy for programmers to switch to Java or vice versa.
Features of Java:
1) Simple. Java is easy to learn and it's syntax is quite simple, clean and easy to understand. The confusing and ambiguous concept of C++ are either left out in Java or they have been re-implimented in a cleaner way.
Example- Pointers and operator overloading are not there in Java but we're an important part of C++.
2) Object oriented. In Java, everything is an object which has some data and behaviour. Java can be easily extended as it is based on object model.
Some basic concept of OOP's are-
(i) Object
(ii) Class
(iii) Inheritance
(iv) Polymorphism
(v) Abstraction
(vi) Encapsulation
3) Robust. Java makes an effort to eliminate error prone codes by emphasizing mainly on compile time error checking and runtime error checking but the main areas which Java improved were memory management and mishandled exceptions by introducing automatic garbage collector and exception handling.
4) Platform independent. Unlike other programming languages such as C, C++ etc which are compiled into platform specific machines. Java is guaranteed to be write once, run anywhere any language.
On compilation Java program is compiled into byte code. This byte code is platform independent and can be run on any machine. This byte code formate also provide security. Any machine with Java run time environment can run Java program.
Java program — [Byte code] - {Linux OS
Windows OS
Mac OS}
5) Secure. When it come to security, Java is always to first choice. With Java secure features it enable us to develop virus free, temper free system. Java program always runs in Java runtime environment with almost null interaction with system OS, hence, it is more secure.
6) Multi threading. Java multi threading feature make it possible to write program that can do many tasks simultaneously. Benefits of multi threading is that is utilizes same memory and other resources to execute multi threads at the same time, like while typing, grammatical errors and checked along.
7) Architectural neutral. Compiler generates byte codes, which have nothing to do with a particular computer architecture. Hence, a java program is easy to interpret on any machine.
8) Portable. Java byte code can be carried to any platform. No implementation dependent features. Everything related to storage in predefined
Example- size of primitive data types.
9) High performance. Java is an interpreted language, so it will never be as a compiled language like C or C++. But Java enables high performance with the use of just-in -time compiler.
10) Distributed. Java is also a distributed language. Programs can be designed to run on computer networks. Java has a special class library for communicating using TCP/IP protocols. Creating network connections is very much easy in Java as compared to C/C++.
Java keywords:
There are 50 keywords in Java i.e.
abstruct byte class do extends for import long private short switch throws volatile |
assert case const double final goto instance of native protected static synchronized transient while |
boolean catch continue else finally if int new public strictfp this try |
break char default enum float implement interface package return super throw void |
Data types in java:
In java there are two types of data types-
- Primitive
- Non primitive
1. Primitive data types-
- Numeric
- Non numeric
- Numeric -
(ii) floating point - float, double
- Non numeric -
2. Non primitive data types-
- class, array, interface