Page 42 - CA_Blue( J )_Class10
P. 42

3.4.5 Separators
              They are the special characters used to separate the variable or characters in a Java Program. E.g.: Braces: ( ), { }, [ ]
              and Comma ' , '

                   Name          Symbol                                     Description
               Comma                 ,       is used to separate multiple variables under the same declaration
               Parentheses          ()       are used to enclose any relational or mathematical expressions.
               Curly Braces         {}       are used to enclose a group of statements under a single statement.
               Square Brackets      []       are used to enclose the index number or cell number of a dimensional array.

              3.4.6 Punctuators
              Punctuators are special characters in Java used as punctuation signs. For examples:
                     Name              Symbol                                   Description
                                                    Each and every statement in Java ends with a semicolon. Hence, it is also
               Semicolon                  ;
                                                    known as a statement terminator.
               Dot                        .         It allows us to access data members and member methods of the class.


                   3.5 DATA TYPES
              A data type is a category that specifies the possible values in a variable or data structure and how those values are
              stored in the computer's memory. Different data types allow you to select the type appropriate for the needs of the
              application. There are two types of data types in Java which are:

                                                           Data Types





                                  Primitive                                             Non-Primitive
                  Integer, Floating-point, Character and Boolean                 Classes, Arrays and Interfaces

              3.5.1 Primitive Data Types
              Primitive data types are predefined or built-in data types in the Java programming language. These are fundamental or
              basic data types. There are four types of primitive data types in Java. Let us study  these data types in detail.

              Integer Type
              Integer types can hold whole numbers such as 123 and −96. The size of the values that can be stored in the variables
              depends on the integer type that we choose.
              Valid integer types are:
              •  byte: The byte data type is an 8-bit signed integer. It can store values between -128 to 127 (both extreme values are
                 included). The default value of the byte data type is 0. It is used to save memory in large arrays because a byte is 4
                 times smaller than an integer. It can also be used in place of the "int" data type. For example:
                 byte a = 1;
                 byte b = -20;
              •  short: The short data type is a 16-bit signed integer or equal to 2 bytes. It is greater than the byte data type in terms
                 of size and less than the int data type. Its range is -32,768 to 32767. The default value of the short data type is 0. For
                 example:
                 short s = 10000;
                 short r = -5000;




                4040  Touchpad Computer Applications-X
   37   38   39   40   41   42   43   44   45   46   47