Posts

Showing posts with the label Exception Handling

Quick Refresh : Spring : AOP, JDBC Template, Exception Handling

Aspect oriented programming (AOP):  Aspect-oriented programming, or AOP, is a programming technique that allows programmers to modularize crosscutting concerns, or behavior that cuts across the typical divisions of responsibility, such as logging and transaction management. The core construct of AOP is the aspect, which encapsulates behaviors affecting multiple classes into reusable modules. There are various common good examples of aspects like logging, auditing, declarative transactions, security, caching, etc.  Aspect:  An aspect is the cross-cutting functionality that you are implementing. It is the aspect of your application you are modularizing. An example of an aspect is logging. Logging is something that is required throughout an application. However, because applications tend to be broken down into layers based on functionality, reusing a logging module through inheritance does not make sense. However, you can create a logging aspect and apply it thr...

Quick Refresh : Java : Exception Handling

Image
Java : Exception Handling Q1) What is an Exception? Ans) The exception is said to be thrown whenever an exceptional event occurs in java which signals that something is not correct with the code written and may give unexpected result. An exceptional event is a occurrence of condition which alters the normal program flow. Exception handler is the code that does something about the exception. Q2) Exceptions are defined in which java package? Ans)All the exceptions are subclasses of java.lang.Exception Q3) How are the exceptions handled in java? Ans)When an exception occurs the execution of the program is transferred to an appropriate exception handler.The try-catch-finally block is used to handle the exception. The code in which the exception may occur is enclosed in a try block, also called as a guarded region. The catch clause matches a specific exception to a block of code which handles that exception. And the clean up code which needs to be executed no matter the exception occur...