class C { int a, b, c; public void setA(int i) {a = i; assert validateC() : c;} public void setB(int i) {b = i; assert validateC() : c;} private boolean validateC() { return c > a + 2 * b; } public int m1(int i) { c = a + b + i; assert validateC() : c; return c; } public C(int i) { c = i; assert validateC() : c; } public static void main(String[] args) { C c = new C(251); c.setA(50); c.setB(100); }} Which statements are true?

  1. If assertions are not enabled at run time it prints an error message.

  2. If assertions are not enabled at run time it prints nothing.

  3. With assertions enabled it prints an error message.

  4. With assertions enabled it prints nothing.

  5. The assert statement is being used to check a class invariant--something that must be true about each instance of the class

  6. The assert statements are being used to check a precondition--something that must be true when the method is invoked.


Correct Option: B,D,E

Find more quizzes: