What is the difference between runtime exception and compile time exception?

Member

by zella , in category: Technology , 3 years ago

What is the difference between runtime exception and compile time exception?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by irwin , 3 years ago

An exception that occurs at compile time is called a checked exception. This exception cannot be ignored and must be handled carefully. For example, in Java if you use FileReader class to read data from the file and the file specified in class constructor does not exist, then a FileNotFoundException occurs and you will have to manage that exception. For the purpose, you will have to write the code in a try-catch block and handle the exception. On the other hand, an exception that occurs at runtime is called unchecked-exception Note: Checked exception is not handled so it becomes an unchecked exception. This exception occurs at the time of execution.