What will be the value of variable "totalParams" after line 7;if the following code is executed from command line as -
java -ea AssertTest?
(Assume that the code is compiled and run with assertions enabled)
1.public class AssertTest
2.{
3.public static void main(
String args[])
4.{
5.int count = args.length;
6.assert (Math.abs(count) == count);
7.int totalParams = count;
8.//more code
9.}
10.}
The Ans for the above question is given
It will throw an AssertionError at runtime at line 6, and statements after that line are not executed;hence value of totalParams can not be determined
I think this is wrong, it will print 0 as output.
kindly correct me If i am wrong..
Thanks in advance.