Java is Strongly typed

 In java every variable and every expression has some type.Each and every datatype is clearly defined.Every assignment will be checked by the compiler for type compatibility.Because of the above reasons we can conclude that java is strongly typed language.

Example:  byte b = false; // compile time error: incompatible types

                                                                                found: boolean

                                                                                 required: byte

Another example: Consider the code snippet

            x=0;

            if(x)

            { System.out.println(" Yes"); }

            else

            { System.out.println(" No"); }

     //compile time error: incompatible types

                                        found: int

                                        required: boolean                                     

Comments

Popular posts from this blog

Enhanced for - loop or for-each loop

Arrays

Constructors