Core Java 면접 질문과 답변
Question: What is Checked Exception and its use in java?Answer:Checked Exception in Java is all those Exception which requires being catches and handled during compile time. If Compiler doesn’t see try or catch block handling a Checked Exception, it throws Compilation error. All the Exception which are direct sub Class of Exception but not inherit RuntimeException are Checked Exception. Use of Checked Exception: 1) All Operation where chances of failure is more e.g. IO Operation, Database Access or Networking operation can be handled with Checked Exception. 2) When you know what to do (i.e. you have alternative) when an Exception occurs, may be as part of Business Process. 3) Checked Exception is a reminder by compiler to programmer to handle failure scenario. Example of checked Exception in Java API Following are some Examples of Checked Exception in Java library:
|
복습용 저장
이 항목을 북마크하거나, 어렵게 표시하거나, 복습 세트에 넣을 수 있습니다.
도움이 되었나요? 예 아니요
Most helpful rated by users:
- How could Java classes direct program messages to the system console, but error messages, say to a file?
- What are the differences between an interface and an abstract class?
- Why would you use a synchronized block vs. synchronized method?
- How can you force garbage collection?
- What are the differences between the methods sleep() and wait()?