Category Archives: JAVA

Final, finally and finalize

What is the difference between final, finally, and finalize? Despite their similar sounding names, final, finally and finalize have very different purposes. To speak in very general terms, final is used to control whether a variable, method, or class is … Continue reading

Posted in JAVA | Leave a comment

Finally block

In Java, does the finally block get executed if we insert a return statement inside the try block of a try-catch-finally? Yes, it will get executed. The finally block gets executed when the try block exists. Even when we attempt … Continue reading

Posted in JAVA | Leave a comment

The effect of keeping a constructor private.

In terms of inheritance, what is the effect of keeping a constructor private? Declaring the constructor private will ensure that no one outside of the class can directly instantiate the class. In this case, the only way to create an … Continue reading

Posted in JAVA | Leave a comment