Page 59 - iPro_trackGPT_V5_Class8
P. 59

Data Type  Size (in bits)              Minimum Value                     Maximum Value
                 double        64                4.9E –324                          1.7976931348623157E308
                 boolean       1                 True or False

                 Non-Primitive Data Types

                 Non-primitive data types are derived from the base data types and make reference to objects. It is
                 also called reference data types. Examples of non-primitive data types include classes, interfaces,
                 and arrays.
                 Literals

                 A literal represents a fixed value in Java. There are different types of literals:

                    Character Literal: It is  enclosed in single quotes and contains exactly one character.
                    For example, 'a' represents the letter 'a.'.
                    String Literal: Always enclosed in double quotes. It may be the alphabet, numbers, special
                    characters, blank spaces, etc. "Hello World" and "123" are examples of a string literal.
                    Integer Literal: A whole number without a decimal point. For example, 10 and 012 are integer
                    literals.
                    Floating-Point Literal: Any number with a decimal point, such as 3.12, is a floating-point
                    literal.
                    Boolean Literal: It represents either true or false and does not correspond to numeric values
                    like 0 or 1.

                 Variables

                 Variables are memory locations where values are stored. When you create a variable, the computer
                 allocates space in memory for it. This memory space is identified by the name assigned to the
                 variable. It is easy to create a variable in Java."
                 Declaring a Variable

                 In Java, you must declare a variable before using it. Declaring a variable involves two steps:
                 naming the variable and specifying the type of data it will store.
                 For example,
                        int age;
                        String name;
                        float temp;
                        double price;

                 Here, four variables named age, name, temp, and price are declared with the int, String, float, and
                 double data types, respectively.



                                   Think, if comments in Java are  secret messages from a wise mentor.  What
                                   advice or tips would you leave in your code for future  programmers  to
                                   discover?





                                                                                              Program Coding     57
   54   55   56   57   58   59   60   61   62   63   64