If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception.
Immanuel Marimuthu wrote:The reason was due to java.lang package
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
so it was my job to see if its actually thrown or not
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Raju Champaklal wrote:if an exception is a checked exception or has any subclasses that are checked exceptions and some are unchecked exceptions....then why does the compiler give that the given exception must be declared to be thrown or caught???
the compile doesnt complain that the exception isnot thrown when it has a unchecked subclass exception then why does the compiler complain when thhat exception is thrown without catching it decalring it to be thrown?
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Raju Champaklal wrote:you said that since Exception has a checked Exception subclass and an unchecked exception subclass we can use a try block without actually throwing an exception in the try block since the comipler knows that a runtime exception can be thrown so it doesn check.......but my question is then why do we have to provide a try catch block in the first place....
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Raju Champaklal wrote:Exception has both checked and unchecked and unchecked are not checked by the compler so why do we need to catch new Exception().....
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Raju wrote:is it true that every class that has both unchecked exceptions and checked exceptions has subclasses will itself be called a checked exception
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Raju Champaklal wrote:dude but isnt RuntimeException a subclass of Exception class?
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown