Page 155 - Computer science 868 Class 12
P. 155

•  Identifiers
                 •  Special Symbols
                 •  Operators
                 Let us discuss them one by one.


                     6.1 KEYWORDS
                 Keywords are the predefined words in Java. Each keyword has a special meaning in Java language. The keywords in
                 the programming language specify the predefined actions. They cannot be used as the names of variables, methods,
                 classes, or any other identifier. They are also known as reserved words.
                 Some of the keywords are given in the table below:

                                                        List of keywords used in Java

                            abstract             else                 int                 static
                            boolean              enum                 interface           strictfp
                            break                extends              long                super
                            byte                 false                native              switch
                            case                 final                new                 synchronized
                            catch                finally              null                throw
                            char                 float                package             throws
                            class                for                  private             transient
                            const                goto                 this                true
                            continue             if                   protected           try
                            default              implements           public              void
                            do                   import               return              volatile
                            double               instanceof           short               while


                     6.2 LITERALS
                 Literals are the different constant values used in Java that are assigned to a variable. They can be used for some
                 calculation or other purpose as per the logic of the program. These literals remain fixed throughout the program. They
                 are also called constants. These values can be of any data type.

                 In Java, there are mainly six different literals. They are as follows:
                 1.  Integer Literals: They are the number constants that are represented without any decimal point. In other words,
                   the whole numbers of any length which are used in coding are known as integer literals. They may be positive or
                   negative.
                   For example: 95, -456, 1254678, etc.
                   There are further three different types of integer literals that can be used in Java which are listed below.
                   •  Decimal Literals: 564, 986, etc.
                   •  Octal Literals: 342, 675, etc.
                   •  Hexadecimals: AB5, 32E, etc.

                 2.  Real Literals: They are also called floating-point literals. They are the number constants with decimal points and
                   are written either in fractional form or exponent form. Like integer literals, they may be positive or negative real
                   integers.
                   For example: 65.36, -2.56, 0.0025, etc.




                                                                                                                       153
                                                                                               Variables and Expressions   153
   150   151   152   153   154   155   156   157   158   159   160