Checked vs Unchecked

This lesson introduces the type of exceptions.

We'll cover the following...
1.

What are the different types or kinds of exceptions?

0/500
Show Answer
1 / 3
Press + to interact
Java
class Demonstration {
public static void main( String args[] ) {
print("Code compiles without throws clause for unchecked exceptions.");
}
static void print(String str) {
if (str == null)
throw new RuntimeException("");
System.out.println(str);
}
}
1.

What are runtime exceptions?

0/500
Show Answer
Did you find this helpful?
Press + to interact
Java
class Demonstration {
public static void main( String args[] ) {
printInt(null);
}
// throws NullPointerException
static void printInt(Number number) {
System.out.println(number.intValue());
}
}
1.

What are Error exceptions?

0/500
Show Answer
1 / 3
Press + to interact
Java
class Demonstration {
public static void main( String args[] ) {
System.out.println( "Hello World!" );
}
// Doesn't compile because the checked exception being
// thrown is checked.
void uselesslMethod() {
throw new IOException();
}
}

Note if the method threw an Error or a ...