JAVA General:
- What are the access modifiers & Scopes?
- Can we change access modifier in method during overriding in child class?
- Can we change void to int type in java main() method?
- Can you overload or override static methods?
- What is static block? When is it executed? Why we need them?
- What is difference between nested class & inner class (static class) ?
- What is Anonymous class?
- Can we make any outer( normal class) as static class? Then why not?
- How to increase memory size i.e, Heap & Stack size in java?
- How arrays are implemented in java? What is the use of Arrays class?
- Difference between Abstract class & interface?
- Can you instantiate abstract class object? Can we have a constructor in abstract class?
- How to detect memory leaks in java?
- How Garbage collector works in java? How to invoke it ondemand?
- What are the changes in Java 7 & Java 8?
- Write a code to Threadsafe Singleton class?
- Is Java String class mutable? If is it not, then why? How to extend String class?(Tricky)
- What is string pool?
- How to create immutable userdefined class?
- StringBuffer vs StringBuilder?
- Why java does n't support Multiple inheritance?
- What is are things in java that are not Serializable? (like transcient, Static).
- How to make arraylist not modifiable after certain data limit
- Volatile
- Executor or concurrency framework
- Race condition in threads
- What is the contract between hashcode and equals
- If two different objects have same hashcode & equals method returns false of comparing two objects, How hashmap inserts data in this scenario?
- How to implement Abstraction in java other than abstract class approach?
- As shown in diagram below, Bird, Animal, Penguin all are Concrete classes. Convert them as class in java?
EXCEPTION HANDLING:
- Difference between Error & Exception in java?
- Is it valid to catch Error in java?
- What is class to override if you want to create your custom Exception?
- What is Checked & Unchecked Exception (or Compile time expception vs Run time Exception)?
- Exception Class hierarchy in java?
- What would be the correct exception class to throw a exception from method when you find NullPointerException in that method?
- How to handle NullPointerException?
- Difference between ArrayList & LinkedList?
- If you have thousands of record which needs frequent insert, update, delete operations, What collection type would choose?What are all scenarios involved in choosing right collection type?
- How does HashSet works? (internal implementation)
- What is the contract between equals() & hashCode() method?
- What happen if you insert duplicate values in HashSet? (what happen to duplicate values? will it throw a exception if it finds to insert duplicate value?)
- How to store userdefined class in HashSet based on any one attribute in userdefined class? (Say you have Employee(id,name,grade) class) you need to store employee class based on id, i.e id should not be duplicate here)
- How to Sort values in TreeSet based on a attribute from Userdefined class( Similar like in previous question, need to sort values based on employee id or by name )
- How HashMap works?(internal implemention)
- How does HashMap retreives the values with given key? (How hashing works in HashMap?)
- What happen if you insert duplicate keys in HashMap, but those keys have different values?
- What is load factor in HashSet & HashMap?
- What is ConcurrentHashMap?
- How to create unmodifiable Arraylist after inserting some values in it?
- Difference between Comparable & Comparator?
- What are the uses of Collections class? (It is not collection interface )
- Difference between HashMap & HashTable?
- What is generics? What are benefits of Generics?
- What are all the ways available to create thread in java?
- What is Volatile keyword? How does it work?
- What is synchronization in java? When actually we need them?
- Difference between Synchornized method & Sychronized block?
- Why notify, wait methods are available in Object class rather than Thread class?
- What are the uses of notify & Wait methods?
- What is Callable?
- How to Create Thread pool? (Have you used Executor framework?)
- What are all the ways for interthread communication?
- What is the shortcut to make collection type be synchronized?
- What is racecondition? What is deadlock?
- What are all monitors available in java?
- How to resolve produce consumer problem with collections in java?
- What is double checkedlock?
Serialization:
- What is serialization? How does it works?
- Why do you need Serialization UID? What happen if you don't provide the one?
- What is Externalization? and Serialization & Externalization?
- What are all methods in Serialization? (tricky)
- What is Transient?
- How to include custom properties during Serialization?

thanks for this useful post. Java static keyword interview questions .
ReplyDelete