Interface based method for Lifecycle events in Bean

We will see howe we can use interface to implement the lifecycle events of the bean. You can have two intrfaces. One is InitializingBean and has a method afterPropertiesSet. Other interface is DisposableBean which has the destroy . This method will be fired by Spring when you do not have rerefence to the bean and redy for garbage collection

You can write the followong main() to test this code

Output :