Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

What happens when you try to compile and run the following code?

  1. class StaticDemo{
  2.  
  3.  static int i = 10;
  4.  static {i = i  * 2 ;}
  5.  
  6.  public static void main(String args[]){
  7.   System.out.prinltn(i);
  8.  }
  9.  
  10.  static {i = i / 45 ;}
  11. }
  12.  
  13.  
a. The code will not compile
b. The code will print 10
c. The code will print 20
d. The code will print 5
Your rating: None Average: 3 (1 vote)
Share this

Post new comment

5 + 14 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.