1.10 What will be the result of compiling and running the following program?
public class NewClass2 {
public static void main(String[] args) {
NewClass2 obj = new NewClass2(n);
}
static int i = 5;
static int n;
int j = 7;
int k;
public NewClass2(int m) {
System.out.println(i + ", " + j + ", " + k + ", " + n + ", " + m);
}
{
j = 70;
n = 20;
} // Instance Initializer Block
static {
i = 50;
} // Static Initializer Block
}
A) The code will fail to compile because the instance initializer block tries to assign a value to a static field.
B) The code will fail to compile because the field k will be uninitialized when it is used.
C) The code will compile and print 50, 70, 0, 20, 0 when run.
D) The code will compile and print 50, 70, 0, 20, 20 when run.
What will be the result of compiling and running the following program?
July 17, 2021 in C and CPP