Computer Applications
In what way is static declaration different from dynamic declaration?
Answer
In static declaration, the initial value of the variable is provided as a literal at the time of declaration. For example:
int mathScore = 100;
double p = 1.4142135;
char ch = 'A';
In dynamic declaration, the initial value of the variable is the result of an expression or the return value of a method call. Dynamic declaration happens at runtime. For example:
int a = 4;
int b = Math.sqrt(a);
double x = 3.14159, y = 1.4142135;
double z = x + y;
Related Questions
Define 'Coercion' with reference to type conversion.
Explain the term type conversion. How is implicit conversion different from explicit conversion?
What do you mean by non-primitive data type? Give examples.
Predict the return data type of the following:
int p; double q; r = p+q; System.out.println(r);