Explain Variable declaration

Variable declaration: It is the association of a variable with a specific type. It is significant to make a distinction among the declaration of variables of primitive types and such of class types. The variable of primitive type performs as a container for the single value of its declared type. The declaration of variable of a class type doesn’t automatically causes an object of that type to be constructed and, by default, the variable will encompass the value null. The variable of a class type performs as a holder for a reference to an object which is compatible with the variable's class type. The Java's rules of polymorphism permit a variable of a class type to hold a reference to some object of its declared type or any of its sub-types. The variable with a declared type of Object, thus, might hold a reference to an object of any class, consequently.

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.