CLASS - X (ICSE)
COMPUTER APPLICATION
Variables
®
A
named memory location, whose contains can be changed with in program execution
is known as variable.
®
It is a
combination of "vary + able"
that means its value can be changed.
®
When
you run any program, it consumes memory in RAM till its execution in process.
®
Examples:
Ø
int
counter;
Ø
double
temp;
Ø
String
name;
Ø
int[]
ages;
Ø
char
letters[]
®
String
is a predefined class not a primitive data type.
Types of Variable
There are three types of variables in java
1.
local variable
2.
instance variable
3.
static variable
1) Local Variable
®
A
variable which is declared inside the method is called local variable.
2) Instance Variable or Object
Variable
®
A variable which is declared inside the class
but outside the method is called instance variable.
®
It is not
declared as static.
3) Static variable or Class
Variable
®
A variable that is declared as static is called
static variable.
®
It cannot be local.
Example of types of variables
class TypesOfVariables{
int data=50; //instance
variable
static int m=100; //static variable
void method(){
int n=90; //local
variable
}
}
Comments
1.
Block
or multiple-line comment:
®
Begin
with /* and terminate with */ that spans multiple lines.
2.
Line
comment:
®
Begin
with // and terminate at the end of the line.
3.
Documentation
comment:
®
Begin
with /** and terminate with */ that spans multiple lines.
®
They
are generally created using the automatic documentation generation tool
No comments:
Post a Comment