Java - nehaverma8/Interview GitHub Wiki
- why is string immutable String is immutable because of security and effciency reasons. First of all, string intern pool is a special place in the java heap. When a string is stored, if a string of the same value is already present, the reference to that string is returned. If string was not immutable, then any change would affect the other strings as well.
Hashcode: Hashcode of a string is often used in java. Since string is immutable, its hashcode can be cached and hence its more effecient since it doesn't have to be calculated again and again.
- difference between stringBuffer and string builder StringBuffer is syncronized and hence thread safe but slower.
- how does hashmap work by dividing the objects in buckets determined by hashes created from hashcodes and retireved by euals methods.
- what is checked and runtime exception Checked exceptions are exceptions that are checked at compile time. If some code within a method throws a checked exception, either the method should handle the exception or must throw that exception.
If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception
-
what are the implicit objects in JSP
-
what are the annotation used in web services
-
what are steps required for jdbc connection in java
-
what is the difference between MVC and web services
-
explain the hierarchy of exception Thorwable Error (Unchecked : OutOfMemoryError) Exception
- RuntimeException ( RunTmeException, ClassCastEception, IndexOutOfBound)
- (IOException, SQLException)
-
what is proxy design pattern and builder pattern