ASCII Codes
ASCII
stands for American Standard Code for Information Interchange. It uses 7 bits
code for representing each character. It includes 256 characters but only 128
characters are used while designing and executing a program. ASCII code
represents these characters as numbers, with each letter assigned a number from
0 to 127. The ASCII codes of some of the characters used in Java programming
are shown below:
Characters
|
ASCII Codes
|
Blank space (white space)
|
32
|
0 to 9 (Numbers)
|
48 – 57
|
A to Z (Capital Alphabets)
|
65 – 90
|
a to z (Small Alphabets)
|
97 – 122
|
Tokens
Token is defined as each individual item or component of Java program
that carries some meaning and takes active part in program execution.
Keywords
Keywords are the reserved words which are preserved by the system and
carry special meaning for the system compiler. They have already been defined
in the language and we cannot use them as names for variables or identifiers,
e.g., class, public, throws, for, sqrt, etc.
Identifiers
Identifiers is a term used for naming a block of statements by which
they are identified in a Java program. Identifiers can be a class name, a
function name, an object , a variable name or an interface name. Following are
some naming rules for identifiers:
- Identifier’s name cannot be same with Keywords or Reserved words.
- Identifier’s name always starts with alphabets, not with numbers.
- No special characters are used within an identifiers name except underscore (_) or dollar ($).
- Blank space (white space) is not allowed in between identifiers name.
Literals
The term constants are referred to as literals in Java programs that
remain unchanged during entire execution of the program.
The various types of literals used in Java are as follows:
Integer Literals: The
whole numbers (positive or negative) are known as integer literals. Decimal
point is not allowed in Integer Literals. e.g., 16, 357, 7856, 66845, etc.
Real Literals: Real
literals are also called as floating point numbers. They are the fractional
numbers. The placement of decimal point may not be same in real numbers. e.g.,
3.45, 85.6, 557.65, etc.
Character Literals: A
single letter or a digit or any special symbol enclosed within single quotes is
known as a character literal. It does not take part in arithmetical
calculations. e.g., ‘B’, ‘u’ ‘6’, ‘?’, etc.
String Literals: A
group of characters enclosed within double quotes is known as a String literal.
e.g., “PROCESS”, “System”, “Salary – 2018”, “4357”, etc.
Boolean Literals: Boolean
literals are true and false. A Boolean literal can either be true or false at a
time.
Null Literal: Null
literal denotes the absence of a value. It is used to initialize an object or
array.
e.g., int n = null;
String s = null;
Operators
Operators are the symbols or signs used to specify the operations to be performed in a Java expression or statement.
To know different types of operators and their functions, click here.
Punctuators or Separators
Punctuators or Separators are some punctuation signs or some special characters in Java, which are used to separate the variables or the characters. e.g., comma (,), semicolon (;), dot (.), parenthesis (), brackets {}, etc.
Operators are the symbols or signs used to specify the operations to be performed in a Java expression or statement.
To know different types of operators and their functions, click here.
Punctuators or Separators
Punctuators or Separators are some punctuation signs or some special characters in Java, which are used to separate the variables or the characters. e.g., comma (,), semicolon (;), dot (.), parenthesis (), brackets {}, etc.
Data Types
Date type basically refers to as the types of data,a memory location can hold. Java supports mainly following two types of data:
- Primitive Data Type (Built-in)
- Non-primitive Data Type (User-defined)
Primitive Data Types
Primitive Data Types are the basic or fundamental data types used to declare a variable. There are following 8 primitive data types present in Java:
Types
|
Size
(Bytes)
|
Default
|
|
Integer
|
byte
|
1
|
0
|
short
|
2
|
0
|
|
int
|
4
|
0
|
|
long
|
8
|
0
|
|
Real
|
float
|
4
|
0.0
|
double
|
8
|
0.0
|
|
Character
|
char
|
2
|
\u0000
|
Boolean
|
boolean
|
1 bit
|
false
|
Non-primitive Data Types
A non-primitive data type is one that is derived from primitive data types. We also may say that a number of primitive data types are used together to represent a non-primitive data type. Hence, a non-primitive data type is also called a composite data type.Type conversion
If various types of data are used in an expression, a question
obviously comes to your mind that what type of result it will return after
execution. In fact, the system converts the result into a specific data type
known as Type Conversion. Basically, the data type conversion take place in two
ways as discussed below:
Implicit type conversion
In a mixed mode expression, when the smaller data types are converted
into higher data type automatically, then it is known as Implicit type
conversion. It is also known as Coercion.
e.g., int a;
long b;
long c = a + b;
Explicit type conversion
In a mixed mode expression, when the smaller data types are need to be
converted into smaller data type, which is normally not possible, then we convert
them forcefully using type cast operator ().
This is known as Explicit type conversion. It is also known as Type
casting.
0 Comments:
Post a Comment