Wednesday, 5 February 2014

ICSE 10th Standard Notes – Variables in Java

Variables :

Variables are the storage locations, whose values can be manipulated during the running of the program.

To store the name of a student and the marks of the student, during a program we need the storage locations and variables with a valid names are used to store the value and represent a memory location.

Declaration of the Variable :

The declaration of the variable is done as follows :-

Syntax : data_type variable_name;

Here the data_type is any valid Java Data Type and the variable_name is the valid name of the variable. A variable name is an identifier.

Example: 

int age;
float average;
int month, day, date;

Initialization of the Variable :

A variable with a declared first value is called as variable initialization. Java supports two forms of variable initialization.

Shown below is the first form of Variable initialization.

Example : 
int age = 20;
float average = 78.90;

Shown below is the second form of Variable initialization. This form of initialization is called as the dynamic variable initialization.

The dynamic initialization form initializes the variable with the out come of an expression or statement.

Example : 
int a,b,c;
c=a+b;
double c=Math.sqrt(a);

Scope of a Variable

Scope of the Variable is the region or the area where the variables are accessible. The variables are accessible within the set of braces it is declared.


ICSE 10th Standard Notes – Assignment and Shorthand Operator in Java
ICSE 10th Standard Notes – Expressions in Java
ICSE 10th Standard Notes – Increment and Decrement Operators in Java
ICSE 10th Standard Notes – Boolean Expressions in Java
ICSE 10th Standard Notes – Arithmetic Operators and their precedence in Java
ICSE 10th Standard Notes – Statements in Java
ICSE 10th Standard Notes – Relational Operators in Java
ICSE 10th Standard Notes – Some Operators in Java
ICSE 10th Standard Notes – Shift and Bitwise Operator in Java
ICSE 10th Standard – Comment Statements in Java
ICSE 10th Standard Notes – Constants and Operators in JavaICSE 10th Standard Notes – Escape Sequences in Java


Get Ebooks delivered to your email id

Comments

Subscribe to our channel

Facebook

Powered by Blogger.

Home | Contact Us | DMCA | Terms of Service | Privacy | Advertise

Maven Scientists