Page 107 - computer science (868) class 11
P. 107

Rules for Naming a Variable
                 While naming a variable, we need to follow certain rules. They are as follows:
                 •  A variable name should start with a letter.
                 •  A variable name may contain any number of letters, digits and underscores.
                 •  The name should have a meaning related to the program.

                 •  There should not be any space between the letters in the name of the variable.
                 •  Variable names cannot be reserved words.

                 5.1.4 Punctuators
                 These are punctuation signs and are used in Java as special characters. Some of them are:
                 •  Semicolon (;) is used for the termination of a statement. For example,
                       int a=5;
                 •  Dot operator(.) is used to access the scope of a function. For example,

                       System.out.println() or import java.util.*;

                 5.1.5 Separators
                 They are the special characters in Java, which are used to separate the variable or the character. For example,
                 •  Braces () are used to set the priority of a calculation by enclosing any part of an arithmetic, logical, or relational
                   expression.
                 •  Curly brackets {} are used to enclose compound statements.
                 •  Square brackets [] are used in arrays.


                 5.1.6 Operators
                 Operators are the special symbols that signify the compiler to perform some specific mathematical or non-mathematical
                 operations on one or more operands. Java supports eight types of operators which are as follows:

                 •  Arithmetic Operators: “+”, “-”, “*”, “/”
                 •  Assignment Operators: “=”
                 •  Logical Operators: “&&”, “||”, “!”

                 •  Relational Operators: “==”, “<”, “>”, “<=”, “>=”, “!=”
                 •  Unary Operators: “+”, “-”, “++”, “- -”
                 •  Bitwise Operators: “&”, “|”, “^”, “~”
                 •  Ternary Operators: “?” and “:”

                 •  Shift Operators: (>>), (>>>), (<<), (<<<)


                     5.2 ESCAPE SEQUENCE
                 An escape sequence is a non-graphical character preceded by a backslash (\) having a special meaning for the
                 compiler. It is a command from the keyboard. Some of the escape sequences used in Java are as follows:

                                         Escape Sequence                 Required for

                                               \t         Inserts a horizontal tab.
                                               \b         Inserts a backspace.
                                               \n         Inserts a new line.
                                               \r         Inserts a carriage return.



                                                                                                                       105
                                                                         Primitive Values, Wrapper Classes, Types and Casting   105
   102   103   104   105   106   107   108   109   110   111   112