1. Home
  2. Computing & Technology
  3. Computer Certification

Question 2
 


What will happen when you attempt to compile and run the following code?


public class Static
{
      static
      {
            int x = 5;
      }

      static int x,y;
      public static void main(String args[])
      {
            x--; myMethod();
            System.out.println(x + y + ++x);
      }

      public static void myMethod()
      {
             y = x++ + ++x;
      }
}

         

  Compile time error prints : 1
  prints : 2 prints : 3
  prints : 7 prints : 8

Back to beginning | Next Question



Explore Computer Certification
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Computer Certification

©2009 About.com, a part of The New York Times Company.

All rights reserved.