- Home
- Interview Questions
- Java
31.
what are the categories of exceptions ?
Exceptions are divided into three categories. That are checked exceptions, runtime or unchecked exceptions and errors.
32.
Tell me few about checked exceptions ?
- A checked exception is an unacceptable condition foreseen by the author of a method, but outside the immediate control of the code.
- FileNotFoundException is a checked exception. This exceptions is thrown if the file that the code is trying to access can't be found.
- If a method calls another method that may throw a checked exception, either it must be enclosed within a try-catchblock or the method should declare this exception to be thrown in its method signature.
33.
Tell me few about runtime exceptions ?
34.
What is the use of continue statement ?
The continuestatement is used to skip the remaining steps in the current iteration and start with the next loop iteration.
35.
Tell me few abouts Objects Lifecycle.
- An object's lifecycle starts when it's initialized and lasts until it goes out of scope or is no longer referenced by a variable.
- When an object is alive, it can be referenced by a variable and other classes can use it by calling its methods and accessing its variables.
- Declaring a reference object variable isn't the same as creating an object.
- An object is marked as eligible for garbage collection when it can no longer be accessed.
- we can be sure only about whether objects are marked for garbage collection. we can never be sure about whether an object has been garbage collected.