Exception: An error that happens while a program is running and interrupts its normal flow, such as trying to use a missing value, read a missing file, or divide by zero.
Example
Your code throws a NullPointerException because a customer record wasn't found and the variable was null. The stack trace points to line 87 of OrderService, where you call customer.getName().
Common Exceptions You Will Meet
| Exception | Usual cause |
|---|---|
| NullPointerException (Java) / NullReferenceException (C#) | Using an object that is null |
| IndexOutOfBounds / IndexError | Accessing a list position that doesn't exist |
| FileNotFoundException | Reading a file that isn't there |
| NumberFormatException / ValueError | Converting text like "abc" to a number |
| Timeout exceptions | A database or API taking too long to respond |
Reading a Stack Trace
A stack trace lists the chain of method calls that led to the exception. Read the exception type and message at the top, then find the first line that points to your own code, not a library. That is usually where to start debugging.
Checked vs Unchecked Exceptions (Java)
Checked exceptions, such as IOException, must be caught or declared, so the compiler forces you to think about them. Unchecked exceptions, such as NullPointerException, extend RuntimeException and are usually signs of a bug. This is a common Java interview question; test yourself with the Java interview questions test.
Related terms
- Error Handling: how you respond to exceptions in code.
- Runtime: when exceptions happen.
- Debugging: finding the cause of an exception.
- Logging: recording exceptions so they can be investigated.
Previous term: Escalation | Next term: Expected Stipend
Related guides
- Java Interview Questions Test
- .NET Interview Questions Test
- Technical Interview Questions for Freshers
Frequently asked questions
What is an exception in programming?
An exception is an error that happens while a program runs and stops its normal flow, unless the code handles it.
What is the difference between an error and an exception?
In everyday use they overlap. In Java, Error means serious problems the program usually can't recover from, while Exception covers problems code can handle.
What is a NullPointerException?
It happens when code tries to use an object reference that is null, such as calling a method on it.
What is the difference between checked and unchecked exceptions?
In Java, checked exceptions must be caught or declared. Unchecked exceptions extend RuntimeException and don't have to be.
Explore more internship terms
The IT Internship Glossary explains 199 terms you will hear before and during your internship, with simple definitions and real examples.
Browse all 199 terms