Data Types and Type Casting

There are following types of data type in java as follows:-
Type of Variable                                  Default Value
         byte                                                   0
         short                                                  0
         int                                                      0
         long                                                   0L
         float                                                   0.0f
         double                                                0.0d
         char                                                   null character
         boolean                                              false(0)
         reference                                            null

The concept of default values is applicable on the variables that is declared in a class not in a method.

Casting:
         The process of converting one dataype to another is called casting.

Example:
         float a:
         a = (int)125.45+25;


0 Comments:

Post a Comment