Latest Java interview questions

September 17th, 2007 Admin Posted in Latest Java interview questions No Comments »

1. When we declare a Private Constructor?

Ans. If we dont want the constructor to be visible to the extend classes then we can declare a constructor to be private and also if we want a class to made as a singleton class then we have to declare it has private

2. What is the difference between redirect and forward in the sense.
we want to go forward from one page then come backward then what is the difference between send redirect and forward ?

Ans: If you want to redirect your page which is residing on a different application then you’ll be using response.sendRedirect(), here the request will be forwarded to another application i,e your request will be redirected to another resoure on different application/server
response.sendRedirect(”http://www.somesite.com”);
If you want to forward your request to another page on the same application then you’ll be using the requestdispatcher.
RequestDispatcher rd = ct.getRequestDispatcher(”/servlet/AccountServlet”);
rd.forward(req, res);

3. Design Patterns?

In simple words,usually design pattern is an abstraction of a solution at a very high level.There are types of design patterns,like creational ,behavorial and structural design patterns,all the design patterns are classified into these three specified patterns

we have so many patterns like intercepting filter, DAOs , Session Facade, SingleTon, Front Controller, View Helper, Service To Worker, Value Object, Service Locator, Service Activator etc etc, i cant remember all those things, refer to the OODesign book by Grady Booch and James Rumbough i think

4.What happens when any request comes from a client (Whole scenario)?

–For this question I’ll answer when i have time—

5. How we can compare the equility of two objects not variables?

Ans: using the equals() Method we can compare the two objects

AddThis Social Bookmark Button