Computer Applications
In what way is static initialization of data type different from dynamic initialization?
Values & Data Types Java
62 Likes
Answer
In static initialization, 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 initialization, the initial value of the variable is the result of an expression or the return value of a method call. Dynamic initialization happens at runtime. For example:
int a = 4;
int b = Math.sqrt(a);
double x = 3.14159, y = 1.4142135;
double z = x + y;
Answered By
36 Likes
Related Questions
Explain the term type conversion. How is implicit conversion different from explicit conversion?
Classify the following as primitive or non-primitive data types.
(a) char
(b) arrays
(c) int
(d) classes
Predict the return data type of 'r' and 'n' from the snippet:
int p; float m; r = p+m; n = m/3*(Math.pow(4,3)); System.out.println(r); System.out.println(n);
Explain whether the following assignments are correct or not:
(a) int m =155;
(b) float f = 0.002654132;
(c) String str = 'Computer';
(d) boolean p = false;
(e) String b = "true";
(f) char ch = "apps";
(g) String st= "Application";
(h) double n = 455.29044125;