Page 158 - Computer science 868 Class 12
P. 158
Declaration of variable Assignment of value After execution
int a; a = 100; a = a+200;
A memory location is assigned to In memory location “a”, an “int” The value in the variable is
a variable “a” where an “int” type value 100 is stored. increased by 200 in the same
value can be stored. location.
a = Memory location a = 100 a = 300
Sometimes, it is required to not allow the value of the variable to be changed in the program code. In that case, we
need to use the keyword “final”.
For example,
final int a = 6;
Now, if we want to change the value of a, the compiler will not allow and will raise an error. Let us see the below
program.
As we can see, while trying to change the value of the final variable a, the compiler raised an error saying “cannot
assign a value to final variable a”.
6.4 SPECIAL SYMBOLS
Let us learn about some special symbols as tokens in Java which are called punctuators and separators.
6.4.1 Punctuators
The punctuators are the punctuation marks to be used in programming which have special meanings. They are used
in Java as special characters.
Some of the punctuators are as follows:
• Semicolon ‘;’: It is used as a termination of a statement.
For example: int a = 5;
• Dot symbol ‘.’: It is used to access the scope of a function.
For example: System.out.println(); or
import java.util.*;
6.4.2 Separators
The separators are the special characters in Java, which are used to separate the variable or the character.
The different types of separators used in Java are:
1. Braces ‘{ }’: The opening and closing braces are used to start and end the block of the statements. In other words,
they are used to enclose compound statements.
156156 Touchpad Computer Science-XII

