hi
in one question
class A {
private void m1 (int i) {
assert i < 10 : i; System.out.print(i);
}
public void m2 (int i) {
assert i < 10 : i; System.out.print(i);
}
public static void main (
String[] args) {
A a = new A(); a.m1(11); a.m2(12);
}}
Which statements are true?
a. If assertions are enabled at run time it prints an error message.
b. With assertions enabled it prints nothing.
c. With assertions disabled it prints an error message.
d. With assertions disabled it prints 1112.
e. With assertions disabled it prints nothing.
f. The assert statements are being used to check a precondition--something that must be true when the method is invoked.
g. Method m1 is an example of an improper use of an assert statement: an assert statement should not be used for argument checking in a non-public method.
h. Method m2 is an example of an improper use of an assert statement: an assert statement should not be used for argument checking in a public method.
---------
the answer were a,d,f,h
in this...y With assertions disabled it prints 1112.
and y not With assertions disabled it prints an error message i.e "c" option ?
but when if it is dissable...how complier treat the
word assert in code ?
if it is not declared as identifier.. in above too..its not identifier....w.r.t. diablity of assertion
pls explain
thanx