Question-191. What is the advantage of Properties file ?

Answer- If you change the value in properties file, you don’t need to recompile the java class. So, it makes the application easy to manage.

Question-192. What does the hashCode() method ?

Answer- The hashCode() method returns a hash code value (an integer number). The hashCode() method returns the same integer number, if two keys (by calling equals() method) are same. But, it is possible that two hash code numbers can have different or same keys.

Question-193. Why we override equals() method ?

Answer- The equals method is used to check whether two objects are same or not. It needs to be overridden if we want to check the objects based on property.

For example, Employee is a class that has 3 data members: id, name and salary. But, we want to check the equality of employee object on the basis of salary. Then, we need to override the equals() method.

Question-194. How to synchronize List, Set and Map elements ?

Answer- Yes, Collections class provides methods to make List, Set or Map elements as synchronized:

public static List synchronizedList(List l){}
public static Set synchronizedSet(Set s){}
public static SortedSet synchronizedSortedSet(SortedSet s){}
public static Map synchronizedMap(Map m){}
public static SortedMap synchronizedSortedMap(SortedMap m){}

 

Question-195. What is the advantage of generic collection ?

Answer- If we use generic class, we don’t need typecasting. It is typesafe and checked at compile time.

Question-196. What is hash-collision in Hashtable and how it is handled in Java ?

Answer- Two different keys with the same hash value is known as hash-collision. Two different entries will be kept in a single hash bucket to avoid the collision.

Question-197. What is the Dictionary class ?

Answer- The Dictionary class provides the capability to store key-value pairs.

Question-198. What is the default size of load factor in hashing based collection ?

Answer- The default size of load factor is 0.75. The default capacity is computed as initial capacity * load factor. For example, 16 * 0.75 = 12. So, 12 is the default capacity of Map.

Question-199. What is JDBC ?

Answer- JDBC is a Java API that is used to connect and execute query to the database. JDBC API uses jdbc drivers to connects to the database.

Question-200. What is JDBC Driver ?

Answer- JDBC Driver is a software component that enables java application to interact with the database.There are 4 types of JDBC drivers:

JDBC-ODBC bridge driver
Native-API driver (partially java driver)
Network Protocol driver (fully java driver)
Thin driver (fully java driver)