Explain static initilisation. Write four types static initilisation example.
Answers
Answered by
2
Explanation:
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
0
Explanation:
A Static Initialization Block in Java is a block that runs before the main( ) method in Java. Java does not care if this block is written after the main( ) method or before the main( ) method, it will be executed before the main method( ) regardless.
Similar questions