Round 2 -
Core Java theory questions -
1. how to make a class immutable? What is the use case?
2. What is the difference between deep copy and shallow copy.
3. how do you declare a singleton class? Write code.
4. Consider below statements -
String s1 = "abc"
String s2 = new String("abc")
String s3 = “abc”
what is output of
s1==s2
s1==s3
5. set s;
s.put(new Student("a", 1))
s.put(new Student("b", 2))
s.put(new Student("a", 1))
what is the size of s
6. how are collisions handled in hashmap?
7. worst case time complexity of inserting element to hashmap
8. using multithreading write program to print output numbers from 1 to 100 even numbers should execute by 1 thread and odd by others.
order of numbers 1 - 100 should be maintained