This is because even though you have called toUpperCase on the String object, its contents will not be changed, rather a new string object will be created in the heap memory with all upper case letters HELLO and the original string object remains unchanged. This is the concept of immutability. Hence for performance and security reasons, String is made immutable and final in Java. Also Immutable strings are thread safe.
OOPs concepts in Java 2. Difference between an interface and an abstract class An abstract class can have instance methods that implement a default behavior.
An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods inside an interface are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members private, protected, etc.
Java 8 introduces a new concept of default method implementation in interfaces. More on this here, default methods. In Vector class each method like addget int i is surrounded with a synchronized block and thus making Vector class thread-safe. Internally, both the ArrayList and Vector hold onto their contents using an Array.
When an element is inserted into an ArrayList or a Vector, the object will need to expand its internal array if it runs out of room. A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.
Since HashMap is not synchronized it performs better than Hashtable. Java 5 introduces ConcurrentHashMap which is an alternative of Hashtable and provides better scalability than Hashtable in Java. Methods in HashTable are synchronized. So it is thread-safe Allows one null key and any number of null values.
Does not permit null key and null values. The enumerator for the Hashtable is not fail-fast. What are checked and unchecked exceptions?
Refer to my previous post Exception handling in Java.
Explain the life cycle of a Servlet. This is an important question to know your understanding of Servlets. Consider the below diagram which involves typical use case for servlet life cycle. The following is a typical user scenario involving life cycle methods of servlet.
Assume that a user requests to visit a URL. The HTTP request is received by the web server and forwarded to the servlet container. The container invokes the init method of the servlet. The container invokes the service method of the servlet. The container may, at some point, decide to unload the servlet from its memory.
The memory allocated for the servlet and its objects can then be garbage collected. What is the difference between RequestDispatcher. This is one more question to assess your knowledge in servlets. Forward SendRediret When we use forward method, request is transfer to other resource within the same server for further processing.
In case of sendRedirect, request is transfer to another resource to different domain or different server for further processing. In case of forward, Web container handle all process internally and client or browser is not involved.
When you use SendRedirect, container transfers the request to client or browser so URL given inside the sendRedirect method is visible as a new request to the client. Visually we are not able to see the forwarded address, it is hidden.
In address bar we are able to see the new redirected address it is transparent. Using forward method is faster then send redirect. SendRedirect is slower because one extra round trip is required because completely new request is created and old request object is lost. Two browser requests are required.
When we redirect using forward and we want to use same data in new resource we can use request. But in sendRedirect if we want to use we have to store the data in session or pass along with the URL.
Any kind of online payment when we use, merchant site will redirect us to net banking site which is completely new request, it process our request and again redirect to merchant site.Jan 20, · What is Protected method in Java Java Interview Question And Answer Naresh i Technologies 2, views.
How to Create a Gmail Signature with . Nov 14, · Ajax in php Interview Question and Answer -Part6. KtjavaAdmin. November 14, DWR will be easy to get up and running and plays well with other Java technologies. If you are looking for a client-side and server-side framework that integrates well use DWR.
Hexaware Technologies Interview Questions. Updated Sep 18, Interview Reviews. Experience First round is with basic java programming and second was with Spring, Hibernate and Webservices.
Nothing specific mostly basic coding queations and exercises e.g. logic to find smallest of 3 numbers Answer Question; Hexaware . 12 Tricky Job Interview Questions in Tech and How to Answer Them.
Cameron Chapman; Last updated February 1st, ; 6 Comments Don’t beat yourself up if you botch a question or stumble to find the right answer. The key thing to remember is that confidence, character, and personality can make up for a lot.
Hexaware Technologies Interview Questions. Updated Nov 9, Interview Reviews. Experience Ratings. first I took online test about Java, Spring and Hibernate.
after that I had Skype interview about technical workflow questions on the Spring web app development life cycle. Answer Question; Hexaware Technologies Frequently asked Java interview questions for experience of 2 to 5 years – Part I.
I have faced all these questions in my interviews. It is important that you master the answer for these questions before attending any Java interview. What are the OOP concepts in Java?
From this question, the interviewer will test your understanding of.