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/
_____________________________________________________
-
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()
-
put(): util.HashMap.
- 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.
- 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
- 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 ?
- More the one main method is declare in same class.
- These are the following steps involved in the process .
- 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)
- The program can contain like below
- public static void main(String[] args)
- {
- out.println(“String args”);
- }
- public static void main(int[] args)
- {
- out.println(“int args”);
- }
- But not like this
- public static void main(String[] args)
- {
- out.println(“String args”);
- }
- public static void main(String[] args)
- {
- out.println(“String args”);
- }
- compile time error occurs as “method main(String[]) is already defined in class UrClassName”
______________________________________________________________________________________