Uninitialized
Page 59
Programming Logic and Design by Tony Gladdis
Uninitialized Page 59 Programming Logic and Design by Tony Gladdis
The value of an automatic variable that is declared but not initialized is indeterminate.Some debug implementations will preset uninitialized variables to a known state, such as 0xcccccccc, or my favorite, 0xcacacaca, but that is just a hint that you are doing something very, very wrong if you ever encounter such a value.
If it is a class or instance variable, it gets the default value of false. If it is a local variable (inside a method), it doesn't have a value until you explicitly set one.
A variable declared as final can't be modified, once a value is assigned.
A constant has only the exact value it's declared and can never be changed. A variable can have any number of values assigned. In programming, a variable can be given a value later in the code but can only be changed during runtime if its been declared as a pointer.
A private variable is one that is accessible only to the current class and cannot be accessed by any other class, including the ones that extend from it. A final variable is one that cannot be modified once it is initialized and assigned a value.
It's almost impossible to predict, but the value will be some data left by OS when it was previously used.
Global variables can have any value, in C they are aumaticatically initialized to zero.
Default values are available for any class or instance variable. If you do not specify a value for a class or instance variable the JVM will provide a default value that will ensure that the system does not end up with any unexpected errors because you used a variable that was not initialized. Ex: Public class Test { int I; } In the above class we have just declared an instance variable called 'I' but we haven't associated any value to it. The JVM automatically assigns 0 as the default value to this variable.
Variable
Just type declare then the variable that you desire to assigned a certain constant value on it. Just type declare then the variable that you desire to assigned a certain constant value on it.
Java by default initializes it to the default value for that primitive type. Thus an int will be initialized to 0(zero), a Boolean will be initialized to false.