EXAM Flashcards
An interface is a class that includes:
Abstract public methods and constant values
Interfaces hold values by default how?
Public, static, final
What are the two main uses of interfaces in Java?
1) Implementing a common function throughout many classes
2) Simulate multiple inheritance
What keyword is used when a class uses an interface?
implements
If a method has a code block in an interface, what keyword is used?
default
Do you have to override a default method from an interface?
No
What kind of inheritance does Java use?
Single inheritance
Can you instantiate an object of an interface class?
No
What is a functional interface?
An interface with only one abstract method
What is an exception?
An object that signals an error
What is a major benefit of using exceptions for errors?
Separates the code for errors from the code while running smoothly
Why should exceptions only be used for unusual or catastrophic events?
Exceptions involve a lot of overhead, potentially reducing performance dramatically.
What does a catch block use as a parameter?
An exception object
What are the 4 categories of exceptions?
1) Code or Data Errors
2) Standard Method Exceptions
3) Throwing your own exceptions
4) Java errors
What are all exceptions a subclass of?
Throwable
What are the 2 subclasses of Throwable?
1) Error
2) Exception
Unchecked exceptions are from which class?
The Runtime Class (Error class too)
What are some common runtime exceptions?
ArithmeticException, IndexOutOfBounds, NullPointer
What are the 2 ways to deal with checked exceptions?
1) Confess using “throws” keyword in header
2) try-catch blocks
What block of code is always executed regardless of exceptions?
finally block