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

Question 1

What will happen when you attempt to compile and run the following code? (Assume that the code is compiled and run with assertions enabled.)

public class AssertTest

   {
       public void methodA(int i)
       {
             assert i >= 0 : methodB();
             System.out.println(i);
       }

       public void methodB()
       {
             System.out.println("The value must not be negative");
       }

      public static void main(String args[])
      {
              AssertTest test = new AssertTest();
              test.methodA(-10);
       }
   }

It will print -10
It will result in Assertion Error showing the message -"The value must not be negative".
The code will not compile.
None of these

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.