Questions from Starting Out With Java


Q: What is the call stack? What is a stack trace?

What is the call stack? What is a stack trace?

See Answer

Q: A program’s main method calls method A, which calls

A program’s main method calls method A, which calls method B. None of these methods performs any exception handling. The code in method B throws an ­exception. Describe what happens.

See Answer

Q: What are the differences between a checked and an unchecked exception?

What are the differences between a checked and an unchecked exception?

See Answer

Q: When are you required to have a throws clause in a method

When are you required to have a throws clause in a method header?

See Answer

Q: What does the throw statement do?

What does the throw statement do?

See Answer

Q: What is the purpose of the argument that is passed to an

What is the purpose of the argument that is passed to an exception object’s constructor? What happens if you do not pass an argument to the constructor?

See Answer

Q: What is the difference between the throw statement and the throws clause

What is the difference between the throw statement and the throws clause?

See Answer

Q: If a method has a throw statement, does it always have

If a method has a throw statement, does it always have to have a throws clause in its header? Why or why not?

See Answer

Q: If you are writing a custom exception class, how can you

If you are writing a custom exception class, how can you make sure it is checked? How can you make sure it is unchecked?

See Answer

Q: What does it mean to “throw" an exception?

What does it mean to “throw" an exception?

See Answer