1)Why main method is static? Can we execute a program without main() method? If yes, how?
Yes u can run java without main method , but make sure that your JDK is below 1.7. and above 1.7 it will not be supported.
*Static means it shared all the instance from the class and belong to the object type and not actual objects.
2)How Weak hashmap Works?
Weak hasmap operates like a normal hashmap but use weak reference for key. suppose if the key object doesn't device any reference then both key/value mapping will become appropriate for a garbage value.
3) how a.hascode() used for? how it is related to a.equals(b)?
hashcode() methods returns an int hash value corresponding to an object. It is used in hash based based collection classes. eg Hashtable, Hashmap.
According to the java specification, two objects which are identical to each other using equals() method needs to have same hashcode.
4)what is compile constant in java?
public static final variable are known as compile time constant.
5)How do you print array in java?
you can print an array by using the Arrays.toString() and Arrays.deeptoString() method. since Array does not implemented to String() by itself, just passing an array to the System.out .println() will not print its content but Array.to.String will print each element.
Comments
Post a Comment