22 Conas TCSC 009
22 Conas TCSC 009
Assignment
Identifiers
Keywords
Reserved Words
Camel Notations
Identifiers
An identifier is a name used to identify a variable, function, or any other user-defined
item. An identifier starts with a letter A to Z or a to z or an underscore _ followed by zero
or more letters, underscores, and digits (0 to 9).
C does not allow punctuation characters such as @, $, and % within identifiers. C is a
case sensitive programming language. Thus, Man and man are two different identifiers in
java programming language. Here are some examples of acceptable identifiers: mohd,
zara, abc, move_name, a_123, myname50, _temp, j, a23b9, retVal
Keywords
These reserved words may not be used as constant or variable or any other identifier
names. Java keyword are reserved terms that have special function and a set definition in
the java programming language.
Examples of keyword in java are: - catch, char, case, class, const, abstract, assert,
boolean, float, loop, goto e.t.c
RESERVED WORD
These are the words that cannot be used as object or variable names in a java program
because they are already used by the syntax of the java programming language. Examples
are import, double, null, void, try, public, new e.t.c
CAMEL NOTATIONS
Camel notation is a way to separate the words in a phrase by making the first letter of
each word capitalized and not using spaces. It is commonly used in web programming
and computer naming conventions. It is name after camels because the capital letters
resemble the humps on a camel’s back.
i. Catch
ii. Char
iii. Case
iv. Class
v. Const
vi. Abstract
vii. Assert
viii. Boolean
ix. Float
x. Loop
2. Define Variables
A variable is nothing but a name given to a storage area that our programs can
manipulate. It can also be defined as data items whose value changes at the point of
execution.
Syntax 1
datatype varable_name;
Examples
Syntax 2
DATATYPE
Data types can refer to an extensive system used for declaring variables or functions of
different types. The type of a variable determines how much space it occupies in storage
and how the bit pattern stored is interpreted.
Type of Datatype
i. Primitive data types includes byte, short, int, long, float, double, Boolean and char
ii. Non primitive data types includes string, array and classes
i. Primitive data types specifies the size and type of variable values and it has no
additional methods
there are eight primitive data types in java
Primitive types are predefined (already defined) in Java while Non-primitive types are
created by the programmer and is not defined by Java (except for String).
Non-primitive types can be used to call methods to perform certain operations, while
primitive types cannot.
A primitive type has always a value, while non-primitive types can be null.
A primitive type starts with a lowercase letter, while non-primitive types starts with an
uppercase letter.
The size of a primitive type depends on the data type, while non-primitive types have all
the same size.
char c1 = ‘Hello’;
char c2 = ‘Welcome’;
System.out.println(“character 1 is : ” + c1);
System.out.println(“character2 is : ” + c2);