aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertions Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Assertions" Watch "Assertions" New topic
Author

Assertions

Padmavathi Narayana
Greenhorn

Joined: Jun 16, 2003
Posts: 12
the question is from single topic Dan's exam abt assertions Q.#7
class C {
String m1(int i) {
switch (i) {
case 0: return "A";
case 1: return "B";
case 2: return "C";
default:
throw new AssertionError();
}
}
public static void main(String[] args) {
C c = new C();
for (int i = 0; i < 4; i++) {
System.out.print(c.m1(i));
}
}
}

Which statements are true?
a. With assertions enabled it prints "ABC" followed by an AssertionError message.
b. With assertions disabled it prints "ABC" followed by an AssertionError message.
c. Assertions should not be used within the default case of a switch statement.
d. In this code example an "assert" statement could not be used in place of the "throw" statement.
e. A compiler error is generated.
f. None of the above.
Ans: a,b,d
As a know, when assertion is disabled means it is same as running in jdk version less then 1.4
I ran it in jdk1.3.1 and got a compile time AssertionError not found. So is ans b is correct if my assumption is right.
Padmavathi Narayana
Greenhorn

Joined: Jun 16, 2003
Posts: 12
Sorry, neglet it. I realized my mistake here!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assertions
 
Similar Threads
Assertion
dan exam doubt 11
For Dan's attention:
AssertionError
Dan's Q of Assertion?