Question: What will be the result of compiling and running the following program? Select the one correct answer. (a) The code will fail to compile, because
What will be the result of compiling and running the following program?
![public class MyClass { public static void main (String [] args) {](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1706/9/5/4/05565be0d4739c671706954052165.jpg)
Select the one correct answer.
(a) The code will fail to compile, because of the instance initializer block.
(b) The code will fail to compile, because of the static initializer block.
(c) The code will compile, and print 50, 70, 0, 20, 0 at runtime.
(d) The code will compile, and print 50, 70, 0, 20, 20 at runtime.
(e) The code will compile, and print 5, 70, 0, 20, 0 at runtime.
(f) The code will compile, and print 5, 70, 0, 20, 20 at runtime.
(g) The code will compile, and print 5, 7, 0, 20, 0 at runtime.
(h) The code will compile, and print 5, 7, 0, 20, 20 at runtime.
public class MyClass { public static void main (String [] args) { MyClass obj = new MyClass (n); } } static int i = 5; static int n; int j = 7; int k; public MyClass(int m) { System.out.println (i + ", } = 70; n = 20; // Instance initializer block static (i = 50; } // Static initializer block +n +", " + m);
Step by Step Solution
3.39 Rating (158 Votes )
There are 3 Steps involved in it
c The program will compile and print 50 70 0 20 0 at runtime All fields are given def... View full answer
Get step-by-step solutions from verified subject matter experts
