• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt in Assert statement

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class TestMe
{
public static void main(String a[])
{
// Insert code here
}
}

1.assert true;
2.assert false;
3.assert false : true;
4.assert false == true;
5.assert false : false;

Which line inserted in the program causes an AssertionError to be thrown in TestMe.java? I tried all the options , they all work fine , i mean they dont throw any AssertionError.. Please correct me if i am wrong.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You did enable assertions at run-time?
 
Kalai Selvi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry. I compiled it using -source 1.4 option, but somehow forgot to run using -ea. Now i did it and got the correct answer as i expected. only the first option doesnot throw AssertionError, since assert true is used. All the remaining options throw the Error.
Thanks for reminding me..
 
reply
    Bookmark Topic Watch Topic
  • New Topic