File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertions" Watch "Assertions" New topic
Author

Assertions

Eric Nadar
Greenhorn

Joined: Oct 12, 2012
Posts: 12
Hello
This question is from Skillguru.I tried compiling it and got no output, but the answer is apparently a.I don't understand!



options:
a.runtime exception due to failure at Line 2.
b.Compilation error at Line 1,assert can't take an String object
c.Compilation fails at Line 2, the second expression of assert can't be boolean
d.line 1,2 show a compilation error,as an assert statement can't returns something.
e.The program compiles fine but no output.

Also,can someone please tell me if the second expression of assert can be boolean?!
Eric Nadar
Greenhorn

Joined: Oct 12, 2012
Posts: 12
umm..sorry!..i tried compiling it again using -ea..(had totally forgotten that earlier!..:P)...and now i'am getting NoClassDefFoundError!..what do i do?
Zhenyi Luo
Ranch Hand

Joined: Sep 03, 2012
Posts: 33
Eric Nadar wrote:umm..sorry!..i tried compiling it again using -ea..(had totally forgotten that earlier!..:P)...and now i'am getting NoClassDefFoundError!..what do i do?


I have got "Exception in thread "main" java.lang.AssertionError: false", how did you get NoClassDefFoundError?
Eric Nadar
Greenhorn

Joined: Oct 12, 2012
Posts: 12
Hi Zhenyi Luo!
i compiled it yet again and i got the Assertion Error this time.Don't know what i did wrong before.Thanks..
Eric Nadar
Greenhorn

Joined: Oct 12, 2012
Posts: 12
And yeah..i checked if the 2nd expression of assert can return boolean,and yes it can.Sorry for all the trouble!..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assertions
 
Similar Threads
when return is required
how to compile java source code with assertion ?
Some conflicting points
Function returning two reference variables
assertion related(mock)