What is the main difference between an ArrayList and a Vector? What is the main difference between HashMap and Hashtable?

Vector / Hashtable ArrayList / HashMap Original classes before the introduction of Collections API. Vector & Hashtable are synchronized. Any method that touches their contents is thread-safe. So if you don’t need a thread safe collection, use the ArrayList or HashMap. Why pay the price of synchronization unnecessarily at the expense of performance degradation. As a general rule, prefer ArrayList/HashMap to Vector/Hashtable. If your application is a multithreaded application and at least one of the threads either adds or deletes an entry into the collection then use new Java collections API‘s external synchronization facility as shown below to temporarily synchronize your collections as … Click here to continue…..

When to use an interface?

For polymorphic interface inheritance, where the client wants to only deal with a type and does not care about the actual implementation use interfaces. If you need to change your design frequently, you should prefer using interface to abstract. Coding to an interface reduces coupling and interface inheritance can achieve code reuse with the help of object composition. For example: The Spring framework’s dependency injection promotes code to an interface principle. Another justification for using interfaces is that they solve the ‘diamond problem’ of traditional multiple inheritance as shown in the figure. Java does not support multiple inheritance. Java only … Click here to continue…..

Concept of Refactoring

If you read the XP life cycle, one of the things after we implement the task is code refactoring. Refactoring is the process of changing the software in such a way that it does not change the behavior of the code but on the other hand improves the internal structure. No code can be perfect with architecture, coding conventions, and high reusability at the first level itself. Normally it improves over time. It helps developers to implement the necessary solutions today and improve / make the code better tomorrow. Refactoring is the process of changing the system to improve the … Click here to continue…..


Polymorphism , the third pillar of object-oriented programming, is closely related to inheritance. The prefix poly means many; morph means form. Thus, polymorphism refers to the ability of a single type or class to take many forms. There are times that you will know you have a collection of a general type, for example a collection of Controls, but you do not know (or care) what the specific subtype each of your controls is (one may be a button, another a list box, etc.). The important thing is that you know they all inherit shared abilities (e.g., the draw method) … Click here to continue…..