Discussion :: Assertions - Finding the output (Q.No.4)
|Venkata said: (Jan 21, 2011)|
|"finished" is output|
|Sundar said: (Feb 19, 2011)|
The given answer is correct only. Don't forget to add -ea option while executing the java code.
I have got the following output:
D:\Java>java -ea Test
Exception in thread "main" java.lang.AssertionError: assertion failed
I hope the above output will clear your doubts. Have a nice day!
|Pragya Sharma said: (Jun 1, 2011)|
|Vivek Kumar said: (Jun 22, 2012)|
|What is -ea option? & what does -ea do?. mean javac is for compilation & java is for interpretation.|
|Suyash said: (Oct 9, 2012)|
If we want to execute assertion line then.
With the interpreter we should use -ea to execute assertion line of code.
|Shwets said: (Jul 16, 2013)|
|Could you please explain what is the use of assertion, why to use assertion?|
|Kds said: (Sep 2, 2013)|
|I was running it from eclipse and got finished as answer.|
|Manpreet said: (Jun 23, 2014)|
|I don't understand the use of assertion in java.|
|Dahaf said: (Aug 4, 2015)|
|Assertions help a programmer to declare his assumptions.|
|Tarang Malvaniya said: (Dec 29, 2016)|
|Output is A) finished.|
|Harsh said: (Feb 20, 2017)|
|How to enable ea option in Net bean?|
|Tul Baghresh said: (Jan 24, 2019)|
|How condition x>0 is true?|
|Vikash Bhel said: (Jul 15, 2019)|
And thus x is not greater than 0. So the condition is false.
So, how the answer is correct?
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.