-
OOPs concepts Encapsulation, Abstraction, Inheritance, Polymorphism and explain
-
Exception hierarchy in inheritance
-
Parent child override scenario
-
Can we override static and private method?
-
Difference between Java 7 and Java 8 interface (static methods and default methods introduced)
-
Final, Finally, Finalize
-
Equals and hashcode
-
Why checked exception also called compile time exception, is it occurs in compile time?
-
How to write custom exception?
-
Throw and throws exception
-
Exception order
-
return usage in try, catch and finally block
-
Is finally block always executed?
-
How many ways we can create string object?
-
String constant pool and working of it
-
Why string is immutable?
-
String vs StringBuffer vs StringBUilder
-
How to write your own custom immutable class?
-
Which is good to store passwords char array or string?
-
What is marker interface? (Serializable, Cloneable, Remote) and how and when it works?
-
Collections - List(ArrayList, LinkedList), Set(HashSet, LinkedHashSet, TreeSet), Map(HashMap, LinkedHashMap, TreeMap)
-
Concurrent - CopyOnWriteArrayList, CopyOnWriteArraySet, ConcurrentHashMap
-
List vs Set
-
ArrayList vs LinkedList
-
Custom array list without duplicates (extend array list and override add method)
-
ArrayList al = new ArrayList(); vs List l = new ArrayList<>();
-
Declaring list with final keyword
-
Why set does not allow duplicates?
-
Comparable vs Comparator
-
Fail fast vs fail safe iterator
-
HashMap (can store null keys / values) vs ConcurrentHashMap (cannot store null keys / values)
-
HashTable vs ConcurrentHashMap
-
Collections.synchronizedMap() - HashTable implementation - Entired data structure is locked
-
Internal working of HashMap - hash, bucket index, equals check, Linked List, Load factor, Balanced tree
-
Null key hashmap - 0th index bucket
-
TreeMap working
-
Why wait and notify is declared in Object class instead of Thread?
-
Why are multiple inheritances not supported in Java?
-
Why Java does not support operator overloading?
-
Why String is immutable in Java?
Java runtime saves lot of heap space because different string variables can refer to same variable in the pool. If it is mutable then there is a chance database password, username passed as String can be modified by hackers. It is safe for multi threading which avoids synchronizing for thread safety. Hashcode cached at creation time and makes a great candidate for key in Map and faster than other HashMap key objects.
-
Why character array is preferred to store passwords instead String in Java?
Any change in string will create new string as they are immutable. Whereas in char[] we can set elements to blank or zero. With string there is always risk of printing plain text to log or file, on the other hand if we print char[] it just
prints memory address.String resides in SCP and JVM needs to be restarted to clean up SCP by GC and it will remain in memory for long time.
Memory dump will have string passwords in clear text so passwords should be encrypted.
-
String intern() method
Last active
May 16, 2024 11:48
-
-
Save vengateshm/b39d39526fcf25c447469cbb66b725da to your computer and use it in GitHub Desktop.
Core Java Interview questions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment