Skip to content

Singleton Design Pattern

There are only two points in the definition of a singleton design pattern,

  1. there should be only one instance allowed for a class and
  2. we should allow global point of access to that single instance.

Spring MVC Architecture

Hi EveryOne

Today we will discuss about the Architecture of Spring MVC module.

Spring MVC is the web component of Spring’s framework. It provides a rich functionality for building robust Web Applications. The Spring MVC Framework is architected and designed in such a way that every piece of logic and functionality is highly configurable. Also Spring can integrate effortlessly with other popular Web Frameworks like Struts, WebWork, Java Server Faces and Tapestry.


Spring’s web MVC framework is, like many other web MVC frameworks, request-driven, designed around a central servlet that dispatches requests to controllers and offers other functionality that facilitates the development of web applications. Spring’s DispatcherServlet is completely integrated with Spring IoC container and allows us to use every other feature of Spring.

Following is the Request process lifecycle of Spring 3.0 MVC:

  1. The client sends a request to web container in the form of http request.
  2. This incoming request is intercepted by Front controller (DispatcherServlet) and it will then tries to find out appropriate Handler Mappings.
  3. With the help of Handler Mappings, the DispatcherServlet will dispatch the request to appropriate Controller.
  4. The Controller tries to process the request and returns the Model and View object in form of ModelAndView instance to the Front Controller.
  5. The Front Controller then tries to resolve the View (which can be JSP, Freemarker, Velocity etc) by consulting the View Resolver object.
  6. The selected view is then rendered back to client.

The chapter discuss the various ways of structuring an operating system.

Chapter 02

operating systems chapter 1

Arrays in java

favourite interview question- Hashcode and equals

Hi folks,

Today we are going to deal with interview strategy of hashcode() and equals() method.

By default, these methods are present in Object class of java.lang package.

Let’s discuss these methods one by one.

public boolean equals(Object o);

The equals() method takes an Object type argument and returns a boolen false or true.

This method checks if some object is passed to it as an argument is equal to the object on which the method is invoked or not.

Default implementation of the equals() method in the Object class says: Check whether two different object references, let r1 and r2,  refer to the same object or not. This method  returns true if and only if r1 and r2 refer to the same object. This is equivalent to something like:

if(r1==r2) or not.

The default implementation performs Shallow Comparison, because the Object class has no data members that defines its state.

The implementation classes that overrides this method performs Deep Comparison, by actually comparing the relevant data members.

Equals() method follows Equivalence Relation properties that you might have studied during your school days.

Equivalence Relation follows Reflexive, Symmetric and Transitive in nature.

Let’s see what does it mean, in Java context.

Assume two object references r1 and r2,

Reflexive:  r1.equals(r1) always returns True.

Symmetric: If r1.equals(r2) returns true/false, then

r2.equals(r1) also returns true/false.

means you can use this property interchangeably

Transitivity: If r1.equals(r2) returns true and r2.equals(r3) returns true, then

r1.equals(r3) also returns true.

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Note that it is generally necessary to override the hashCode method, if you are overriding equals() method, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hashCodes.

Relationship status of these methods on FACEBOOK.

If two objects are equal, then they must have the same hash code, however the opposite is NOT true

Synchonized keyword in java

The synchronized keyword is used with the definition of a method. This would ensure that only one thread can enter that method at the same time. Another threads which is calling this method would wait until the first threads leaves this method.