Java is a high- position, object- acquainted programming language that was developed by Sun Microsystems in themid-1990s. It’s designed to be platform-independent, meaning that Java programs can run on any device or system with a Java Virtual Machine( JVM). Then is a detailed explanation of Java.
Contents
Why java
- Java is platform independent means write once run anywhere.
- Java is complete object oriented language.
- Java has a built in support for exception handling.
- Java has a built in support for multithreading application.
- It is provide communication with c/c++ cods through java native interface.
What is the basic element of java?
- Java have various building block.
- Every programing language contain alphabets which encapsulate thing like identifiers, keywords and special symbol.
- Java have some new keyword who maintained its uniqueness.
Identifiers
Rules
- the variables of primitive data types.
- User defined classes.
- Interface
Identifier should not contain the following character:
[] , {} , () , // , * , \ , + , – , , , ; , “ ” , ‘ ’ , # , % , ! , ^ etc.
Unlike c/c++ (doller)$ and (underscore)_ is allowed in java.
WHAT IS THE DIFFERENCE BETWEEN C/C++ AND JAVA (IN 7 Points)
- Java does not support global variable but c/c++ support global variable.
- Through packages java have classes and pre-defined methods.
- Java provide an object-oriented through wrapper class.
- Java have primitive data type like int,float,byte,char,Boolean etc.
- Java does not have header files and processor directive.
- Java local variable supported inside.
- c/c++ provide memory overlappling feature which is junk in java.
Keywords in java
| keywords | Description |
| Abstract | · Abstract is used to declare a class or method.
· Abstract method does not contain its body. · Abstract only has the declaration where its body is defined. |
| Boolean | · In java Boolean is a primitive data type.
· Boolean can have either true or false value. · It represented as an integral value. · Size of a Boolean variable is 8 bit. |
| Break | · Break is used in loops and switch case.
· Break is particularly used to break the normal flow of the program. |
| Continue | · continue is used in do, do-while & for loops.
· It is used for jumps to the condition. |
| Byte | · in java byte is primitive data type.
· Its size is 1 byte or 8 bit. · When used static variable then its default value is zero. · When used instance variable then its default value is also zero. |
| Case | · Case is used to create individual case in switch statement.
· It clause precedes integer constant. |
| Catch | · Catch is a component of exception handling.
· Catch is always follows the try block to catch the exception. |
| Try | · Try is a component of exception handling.
· All the exception generated codes are embedded inside the try block. |
| Class | · Class is the keyword through whish a programmer defines the user-defined class template. |
| Default | · Default is an optional component of switch case.
· When no condition is satisfied then default case is executed. |
| Double | · In java double is a primitive data type.
· Double is store real numbers in 64 bit. |
| Extends | · In java extend keyword is used to support inheritance. |
| Final | · Final is used in case of variables to create constant.
· When final is used in the case of method that method cannot be overridden. · If final is used in the case of class then that class cannot be inherited. |
| Finally | · In java finally is a component of exception handling.
· Whenever try block is executed it’s mandatory that the code inside the finally block be executed. |
| If | · If is used for the purpose of condition checking. |
| Else | · Else is the extension of its own.
· Else is used along with if statement. · Else is used for condition checking. · When if part is not executed then else part is executed. · In if-else statement the else part is optional. |
| Do | · Do is always to make complete with the do while loop. |
| While | · In java while is a keyword used for creating loop. |
| For | · For is used to create a looping statement. |
| Int | · Int is used to store natural number.
· Size of int is 4 bit. |
| Float | · Float is used to store real number.
· Size of float is 32 bit. |
| Char | · Char is primitive data type in java.
· Size of char is 16 bit. · The Unicode character hold by char in java. |
| True | · True is a Boolean constant. |
| False | · False is a Boolean constant. |
| Switch | · It is basically used for condition checking. |
| Implements | · Implement is used to inherit multiple number of interface. |
| Import | · Used to import existing package.
· Location of package is class file. |
| Instanceof | · Instanceof is a binary operator.
· Instanceof used to determine the parent-child relationship between two objects. |
| Long | · Long is used to store integral value.
· Size of long is 8 byte. |
| Null | · Null is a reference literal value.
· Null can only be assign to reference variable. · When a reference variable is created in side stack its default value is null. |
| Package | · Package keyword is used to declare a package.
· Its collection of class file. |
| Private | · Private is an access modifier.
· If an entity inside a class is declared as private private class cannot be inherited to its child class. · Private variable are not only accessed inside the class. |
| Protected | · Protected is an access specifier.
· Protected entities are accessed outside the package through inheritance. |
| Public | · Public is an access specifire.
· Public variable can be accessed from anywhere. |
| Return | · Return is used to return control from a method along with a value. |
| Short | · in java short is a primitive data type.
· Size of short is 8 bit. |
| Static | · Its an associate with a method and a constructor.
· Its related to a class variable. · Its entities are through a class name. |
| This | · It is used by an object to refer to itself. |
| Throw | · throw is a component of java exception handling.
· It’s used to throw an exception object. |
| Throws | · Throws is used along with the method signature.
· Throws is used by the call method to throw the unhandled exception to the calling method. |
| Transient | · Transient is used for the variables.
· When the programmer does not want to store permanently. |
| Void | · If a method does not return anything then void is used to denote its return type. |
| Volatile | · Volatile is used along with a variable name.
· It change its value without informing. |