Fresher Java Interview Questions in Auromine Solutions – Part – IV

Fresher Java Interview Questions in Auromine Solutions – Part – IV

This blog explains about  Fresher Java Interview Questions in Auromine Solutions – Part – IV . Some of them are discussed below : 

 We have already discussed some questions in the previous blogs. Let us see few more questions Fresher Java Interview Questions in Auromine Solutions – Part – IV.   

REFERENCES :  Fresher Java Interview Questions in Auromine Solutions – Part – I , II  & III

https://payilagam.com/blogs/fresher-java-interview-questions-in-auromine-solutions-part-i/

https://payilagam.com/blogs/fresher-java-interview-questions-in-auromine-solutions-part-ii/

https://payilagam.com/blogs/fresher-java-interview-questions-in-auromine-solutions-part-iii/

_____________________________________________________

  1. Explain  briefly about  Hash Map  ? 

HashMap is a data structure that uses a hash function to map identifying values, known as keys, to their associated values. It contains “key-value” pairs and allows retrieving value by key.

The most impressive feature is it’s fast lookup of elements especially for large no. of elements. It is not synchronized by default . 

These are various important hashmap class methods.

This post explains: put(), get(), isEmpty() and size()

  1. put(): util.HashMap.

  2. put() plays role in associating the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.

Syntax:

public V put(K key,V value)

Parameters:

key – key with which the specified value is to be associated

value – value to be associated with the specified key

Return: the previous value associated with

key, or null if there was no mapping for key.

  2.get(): util.HashMap.

  1. get()method returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Syntax:

public V get(Object key)

Parameters:

key – the key whose associated value is to be returned

Return: the value to which the specified

key is mapped, or null if this map contains no mapping for

the key.

3. Empty(): util.HashMap.

isEmpty() method returns true if the map contains no key-value mappings.

Syntax:

public boolean isEmpty()

Return: true if this map contains no key-value mappings

  1. size(): util.HashMap.size() returns the number of key-value mappings in this map.

Syntax:

public int size()

Return: the number of key-value mappings in this map.

_______________________________________________________________________________

2. Explain more than one main method to declare in same  class ?

  1. More the one main method is declare in same class. 
  2.    These are the following steps involved in the process  . 
  3. A  java program can contain more than one “main” method,but the arguments should not be(String[] args) except for one main method(Means we can have overloaded main method in a class)
  1. The program can contain like below
  2. public static void main(String[] args)
  3. {
  4. out.println(“String args”);
  5. }
  6. public static void main(int[] args)
  7. {
  8. out.println(“int args”);
  9. }
  10. But not like this
  11. public static void main(String[] args)
  12. {
  13. out.println(“String args”);
  14. }
  15. public static void main(String[] args)
  16. {
  17. out.println(“String args”);
  18. }
  19. compile time error occurs as “method main(String[]) is already defined in class UrClassName”

______________________________________________________________________________________