Computer Application 3
Computer Application 3
Character Set: A character set is a defined list of characters that a language can
recognize. Java too has a set of characters that it can recognize. The name of Java
character set is Unicode (16 bits character coding system) that is based on ASCII.
ASCII (8 bits) stands for American Standard Code for Information Interchange. It
supports maximum 256 unique characters (alphabets, numbers and special characters).
Unicode supports 65536 unique characters. The first 256 characters of the Unicode
set are identical to the standard ASCII character set. Unicode is used to represent all the
characters found in different languages such as English, Hindi, Chinese, French, etc.
Tokens: The smallest individual unit in a program that is meaningful to the compiler.
There are five categories of tokens in java. These are -
1. Keywords syntax are: curly braces for code block ,
semicolon for the end of statement
2. Identifiers parantheses for parameters , and infix
3. Literals notation for expressions.
4. Operators
5. Punctuators / separators because it uses the c- style
For example: int marks = 98 ; syntax . which is the nobs
of the most programming
| | | | | language.
Keyword Identifier Operator Literal Punctuator
Keywords: Reserved words that have a specific meaning for the java compiler. Java is a
case sensitive language, all keywords are defined in lower case (small letter).
For example - int, double, public, if, for etc.
For example:
my marks Invalid ( due to space)
my.marks Invalid ( due to dot)
myMarks Valid
my_marks Valid
1Marks Invalid (due to begin with digit)
marks1 Valid
else Invalid (due to reserve word)
Computer Applications Notes Volume I (Class IX) for ICSE examinations 2022 by Hem Sir Page 7
Literals: It is a value that remains fixed during the execution of a program. It is also
known as constants. There are six types of Literals in Java-
Operands are the variables or literals on which operator works. For example- in
the statement n = n + 5; =, + are operators and n, 5 are operands.
(We shall discuss operators in detail in chapter-5)
Computer Applications Notes Volume I (Class IX) for ICSE examinations 2022 by Hem Sir Page 8
Punctuators: Predefined Symbols which are used for grouping and separating the code.
Punctuators are-
Data Types: Data types are means to identify the type of data and associated operations of
handling it. The size of a variable and a constant are determined by data types.
Primitive data types: These are fundamental or built in data types and available
as an integral part of Java Programming language. There are following eight
primitive data types-
Type Size Description
byte 1 byte(8 bits) Integer in the range of -128 to 127
short 2 bytes(16 bits) Integer in the range of -32768 to 32767
int 4 bytes(32 bits) Integer in the range of -231 to 231-1
long 8 bytes(64 bits) Integer in the range of -263 to 263-1
float 4 bytes(32 bits) Single-precision (up to 7 significant
decimal digits) floating point
double 8 bytes(64 bits) Double-precision (up to 15 significant
decimal digits) floating point
char 2 bytes(16 bits) Single character, range of Unicode 0 – 65536
boolean 1 byte(8 bits) To represent true(1) or false(0)
Non Primitive data types: These are derived from the primitive data types. So,
these are also called derived types, reference types or composite data types. Classes,
arrays etc. are the examples of reference data types.
Variable: A named location of memory to store data value. The value stored in a
variable can be changed any time.
Computer Applications Notes Volume I (Class IX) for ICSE examinations 2022 by Hem Sir Page 9
Declaring variables: A variable can be used in a java program only if it has been
declared. Syntax to declare variable-
data_type variable_name ;
For example- int marks ;
float principal, rate, time ;
Initialising variable: It means to assign (store) a value to the variable at the time of its
declaration. For example- int marks = 94 ;
float p = 5000.0f, r = 7.5f, t = 5.0f ;
Initialization at run time is known as dynamic initialization. Such as-
float perimeter = 2 * 3.14 * 6;
If we do not initialize the member variables, compiler automatically initializes using
default value. Default value for various type of variables are-
Data Type Default value
byte 0
short 0
int 0
long 0L
float 0.0f
double 0.0d
char ‘\u0000’
boolean false
reference data type ‘\u0000’ (null)
Constants: In Java, the keyword final can be used in a variable declaration to make a
variable as a constant (It means we cannot change the value of a variable once it has
been initialized).
Constant makes the code easier to understand, prevents any unintentional changes,
a change at one place reflects all automatically.
For identification, constants are generally declared in capital letter.
A complete example using variables and constant-
public class Circle
{
public static void main (String args[])
{
final double PI = 3.14 ; // constant
float radius = 6.5f ; // variable
double area = PI * radius * radius ; // calculating and initializing
System.out.println(“Area of Circle =” + area); // displaying area
}
}
Note : In same way you can practice for more programs with the help of your book.
Computer Applications Notes Volume I (Class IX) for ICSE examinations 2022 by Hem Sir Page 10