Problema 11
class CheckedException extends Exception{
}
class UncheckedException extends RuntimeException{
}
class TestException{
public void TestingCheckedException()throws CheckedException{
throw new CheckedException();
}
public void TestingUncheckedException(){
throw new UncheckedException();
}
}
public class Main {
public static void main(String[] args) {
TestException test=new TestException();
test.TestingUncheckedException();
try {
test.TestingCheckedException();
}catch(CheckedException e1) {
System.out.println("Exceptie verificata");
}
}
}
Exceptiile de tipul "unchecked" ne lasa sa compilam programul fara a avea un bloc "try-catch" sau "throws numeExceptie" .
Exceptiile verificate nu ne lasa sa compilam programul fara a avea blocul "try-catch" sau fara a avea "throws numeExceptie".