In an array-based implementation of a stack, an operation that needs to add a new element to the stack may not be able to complete because the array is full. In this case, the failed operation should

A) print an error message and return from the method
B) throw some appropriately defined exception
C) print an error message and exit
D) alert the user before continuing execution

B) throw some appropriately defined exception

Computer Science & Information Technology

You might also like to view...

Which of the following is not a helpful package for XML parsing on the Android platform?

a. android.util.Xml b. android.java.Xml* c. org.w3c.dom d. org.xmlpull.*

Computer Science & Information Technology

To signal a failure on the input stream accessed by infile, use the statement

a. infile.fail(); b. infile.reset ( ios::failbit ); c. infile.setstate ( ios::failbit ); d. infile.eof();

Computer Science & Information Technology