Java Language fundamentals and its Operations

Java Language fundamentals and its Operations

Java Keywords

Java Keywords are reserved identifiers that are predefined in the Java language. We should not use Java Keywords as Class names,Method names,or Variable names.

Java keywords are in lowercase letters only.
Java keywords not uses Special symbols like $%^ Etc., All the keywords contains letters only.

List of Keywords

Variables in Java

Java variable are used to store the different type of values in it.

Declaration of Java Variables

  = initial value ;

Where Data-type indicates that type of value that variable can hold. Name is given to the variable to identify easily.

Example: int age=21; String name=”Ram”; etc.,

Types of Variables in Java

  • Primitive Variables:

    The variables declared with the Primitive data types such as int, long, float, byte etc.,

  • Reference Variables:

    The variables declared with Object, this points to the location of memory where the object is created. Example: Fan f1; etc.,

A Reference variable holds the address of memory where the object is created, and primitive variable hold the value of particular data type.

Initialization of Java Variables

Assigning the values to the variables are called Initialization. Syntax used to Assign the variables are :

= Initial Value ; 
Example: int age= 21; String name= “Ram”; Etc.,

Declaration scope for Variables

There are two types of variable declarations which are

  • Local Declaration
  • Instance Declaration

Local Variables

  1. Local variables declared inside the body of the method.
  2. Variables declared inside the method can be accessible only to inside the method.
  3. Value of the variable can’t be accessed outside the method.

Instance Variables

  1. Instance variables are declared in the the body of the class.
  2. The value of Instance variable can be accessed by the All the methods present in the class.
  3. Value of Instance variable can also accessed by other classes also it is based on the access specifier.

Note :

  • While naming the variables first letter must be letter or an _(underscore) or $(dollar symbol).
  • Keywords cannot be a Java variables.

Leave a Reply

Your email address will not be published. Required fields are marked *