Java
-
How can you make a class Immutable?
Declare the class as a final so it can’t be extended. Make all fields private so that direct access will be avoided. Do not implement setter methods for a variables.…
-
JMS v/s MQ
The difference being that JMS messages have some standard header fields at the begining of the message buffer and “native” mq messages contain just the data your program sent to the buffer. Performance is not the only reason…
-
What will happen if you store null key in HashMap?
In HashMap, only one null key is allowed. If key of the HashMap is null then it will always be present in the index 0. NullPointerException is thrown if you…
-
Can we use any class as a Map key in HashMap?
Yes. We can use any class as a Map key, however the following points should be considered before using them. If a class overrides an equals() method, it should also…
-
What is the importance of hashcode() and equals() methods?
HashMap uses the key object hashCode() and equals methods to determine the index to put the key-value pair. The methods are also used when we try to get the value…
-
How hashmap works in java?
Hashmap stores a key-value pair in Map.Entry static nested class implementation. HashMap works on hashing algorithm and uses hashcode() and equals() method in put() and get() methods. When we call…
-
Difference between enum and constant in java
Enum is a java keyword, we can use it for a variable to be set of predefined constant value. Before Java 1.5 we used public static final keywords to represent…
-
Algorithm Analysis
Runtime Analysis of an Algorithm
-
Binary Search
Binary search is used to search a key element from multiple elements. Binary search is faster than linear search. In case of binary search, array elements must be in ascending order. If you have unsorted array, you…











