what do you mean by the initial value of a variable in Java programming why it is so compulsory also state the default initial value of any two data types
Answers
Answer:
Initial value of a variable is the value assigned to the variable by default or by the user.
It is very important in JAVA because if we do not give or assign any value to a local variable , then the program won't compile .
You will be shocked with this one . The default value of boolean datatype is false ( Life is a beautiful lie ) .
The default value of int is 0 and double is 0.0 .
Explanation:
Few shockers coming your way :
We can find the default value of a datatype by declaring the datatype and the variable outside and then printing it .
class WHAT
{
boolean a;
int b;
public static void main(String hello[])
{
System.out.println(a);
System.out.println(b);
}}
Compile that code and see for yourself . You will understand the default value of boolean and int .
Biggest shocker : The worst output of JAVA is System.out.println(6.0/0.0); which teaches us not to mess with Infinity XD .
Sorry if I cannot reply to comments [ Brainly is full of bugs and I cannot comment due to that :(( ]