Is the following implementation of testPopEmpty() equivalent to that shown in Listing 6.2?

```
1 public void testPopEmpty() {
2 Stack s = new ListStack();
3
4 try {
5 s.pop();
6 fail("testPopEmpty EmptyStackException expected");
7 } catch ( EmptyStackException ex ) {
8 return; // this is what we expect
9 }
10 }

```


They are equivalent. If s.pop() does throw an exception as expected, the fail() method call will not execute as the catch block is immediately invoked. fail() will only be called if s.pop() does not throw an exception.

Computer Science & Information Technology

You might also like to view...

When is a work package defined?

What will be an ideal response?

Computer Science & Information Technology

It is possible for Word to save a file as a Portable Document Format, PDF

Indicate whether the statement is true or false

Computer Science & Information Technology

Which of the following types of activities is NOT commonly performed in preparation for a security assessment?

A. Apply patches. B. Analyze the change management procedures. C. Review the security policies. D. Collect host configuration documentation.

Computer Science & Information Technology

CRL distribution point (CRL DP) is also called ____.

A. complete CRL B. partitioned CRL C. ARL CRL D. indirect CRL

Computer Science & Information Technology