Java Reference Interview Questions
Java Reference Interview Questions
Java Reference Interview Questions
Architecture (JAVA)
1. What is JDK? What are the components present within JDK and brief about their
functionalities?
2. What is JRE? What are the components present within JRE and brief about their
functionalities?
3. What is JVM? What are the components present within JVM and brief about their
functionalities?
Architecture (JVM)
1. What is class loader
2. What is memory area? Brief about the parts of memory area.
3. What is execution engine?
4. What is an interpreter?
5. What is a compiler?
6. What is the difference between javac and JIT?
String
1. What is String?
2. Why String is by default immutable ?
3. Difference between StringBuffer and StringBuilder.
4. List any 5 in-built methods in String with their functionalities.
5. Is String a class , keyword or data type?
6. Different methods to create a String in java.
7. What is the difference between == and equal() in String?
8. What is the difference of creating a String object by using new keyword and
without using new keyword?
9. Explain the immutability of String with the help of a program.
Array
1. What is an array?
2. Why is it mandatory to pass the size while creating an array?
3. Is array size fixed?
4. Can we change the size of an array, once it is being created?
5. Which array can accept all the types of array?
6. Difference between 1d array and 2d array
7. Default value of array
8. Can we add or delete an element after assigning an array?
9. What are the different ways to create an array?
10. Are arrays mutable?
11. What are the different types of arrays?
12. Difference between jagged arrays and rectangular arrays.
Constructors.
1. What are constructors and their types?
2. Can we achieve constructor overloading?
3. Can we achieve constructor chaining?
4. What is the use of this() and super() calling statements?
5. What is the use of this and super keywords?
6. What is the difference between constructors and methods?
7. What is the implicit return type of constructors?
8. Can a sub class constructor inherit super class constructor?
Inheritance
1. What is Inheritance in Java?
2. What are the types of inheritance in Java?
3. Why do we need to use inheritance?
4. What is Is-A and Has-A relationship in Java?
5. What is super class and subclass?
6. How is Inheritance implemented/achieved in Java?
7. Which is the super most class in java?
8. Can a class extend itself?
9. Can we assign superclass object to subclass object reference?
10. Can a class extend more than one class?
11. Are constructor and instance initialization block inherited to subclass?
12. Can we extend (inherit) final class?
13. Can a final method be overridden?
14. Can we inherit private members of base class to its subclass?
15. Why multiple inheritance is not supported in java through class?
16. Can we access subclass members if we create an object of superclass?
17. Can we access both superclass and subclass members if we create an object of
subclass?
18. What happens if both superclass and subclass have a field with the same name?
19. What are the different types of inheritances?
20. When is hybrid inheritance getting supported and when it is not getting
supported?
Polymorphism
1. What is Polymorphism in Java oops?
2. What are the types of Polymorphism in Java?
3. What are different ways to achieve or implement polymorphism in Java?
4. What are the differences between Polymorphism and Inheritance in Java?
5. What is Compile time polymorphism (Static polymorphism)?
6. What is Run time polymorphism (Static polymorphism)?
7. How to achieve/implement dynamic polymorphism in Java?
8. What are the types of binding in Java?
9. Why static binding is also called early binding in Java?
10. Why binding of private, static, and final methods are always static binding in
Java?
11. Is it possible to implement runtime polymorphism by data members in Java?
12. What is Method Overloading and Method Overriding?
13. Why is Compile Time Polymorphism also called as static binding?
14. Why is Compile Time Polymorphism also called as early binding?
15. Why is Run Time Polymorphism also called as late binding?
16. Why is Run Time Polymorphism also called as dynamic binding?
17. What are the disadvantages of method overloading and method overriding?
18. What is the use of @Override annotation?
Abstraction
1. What is Abstraction in Java?
2. How to achieve or implement Abstraction in Java?
3. What is the difference between abstract class and concrete class?
4. Can abstract modifier applicable for variables?
5. What is Abstract method in Java?
6. Can an abstract method be declared as static?
7. Can an abstract method be declared with private modifier?
8. When to use Abstract class in Java?
9. When to use Abstract method in Java?
10. Is it possible to create an object of abstract class in Java?
11. Can an abstract class have constructor?
12. Is it possible to achieve multiple inheritance through abstract class?
13. Can we make an abstract class without abstract keyword?
14. What is the difference between Abstraction and Encapsulation?
15. Why abstract class has constructor even though you cannot create object?
16. Disadvantage of abstraction.
17. What is interface, abstract class, abstract method and concrete method?
18. What are the differences between abstract classes and interfaces?
19. What are the different types of interfaces with examples?
20. What are the differences between abstract classes and interfaces?
21. Why can’t we create objects for abstract classes or interfaces?
22. What is type casting and their types?
23. What is narrowing and widening or implicit and explicit casting?
24. What is upcating and downcasting?
25. Steps to achieve upcating and downcasting?
26. What is casting statements?
27. How can we achieve the 100% abstraction?
28. How to achieve abstraction programmatically?
29. How are we able to overcome the demerits of multiple inheritance in classes over
interfaces in java?
30. Real time application examples for abstraction.
Encapsulation
1. What is Encapsulation in Java? Why is it called Data hiding?
2. How to achieve encapsulation in Java? Give an example.
3. What is the difference between Abstraction and Encapsulation?
4. Can we achieve abstraction without encapsulation in Java?
5. How to achieve encapsulation programmatically?
6. What are getter and setter methods in Java?
7. Difference between data hiding and data binding?
8. What are the steps to achieve encapsulation?
E.g . You have account number 121213133423523 and this property is PRIVATE and
client want to make some modification in the account number. What to do?
Collection Questions:
1. What are the benefits of collection framework over arrays?
2. What are frameworks?
3. What are Collection?
4. Which is the root interface of collection framework?
5. What is Collections?
6. What is the difference between collection and collections?
7. Why should we use collection frameworks?
8. What is the difference between Iterable and Iterator?
9. How is collection helping us to overcome the disadvantages of array?
10. What are the advantages of collection framework?
11. Describe the collection hierarchy in Java.
12. Why collection doesn’t extend Cloneable and Serializable interfaces?
13. What are generics and what is the importance of generics?
14. What are wrapper classes and why are they used?
15. Difference between Comparator and Comparable.
16. How are the collection objects sorted in java?
17. What is List interface? Explain their features.
18. What is ArrayList? Explain it’s features.
19. Difference between ArrayList and Arrays.
20. What is LinkedList? Explain it’s features.
21. What is Vector? Explain it’s features.
22. What is Stack? Explain it’s features.
23. Difference between ArrayList and LinkedList.
24. How to convert ArrayList to Arrays?
25. How to convert Arrays to ArrayList?
26. How to convert ArrayList to LinkedList?
27. Difference between Singly Linked List and Doubly
Linked List.
28. How to set size during object creation for List interface?
29. What is Queue interface? Explain their features.
30. What are the important methods of Queue interface?
28. What is priority queue? Explain it’s features.
29. What is ArrayDeque?
30. What is Set interface? Explain their features.
31. What is HashSet? How is objects stored in it?
32. What is emptySet()?
33. What is LinkedHashSet? Explain their features.
34. What is Map interface? Explain their features. 35. Why Map interface doesn’t
extend Collection interface?
36. Can a class be used as Map key?
37. Difference between HashMap and HashTable
38. Difference between List, Queue and Set interfaces.
39. Difference between Iterator and Enumeration.
40. List out the commonly used methods in collection.
41. Difference between HashSet and TreeSet.
42. Difference between HashSet and Hashtable.
43. What is the difference between push() v/s add(), pop() v/s remove() v/s poll()?
44. Different add() in collection.
45. What is a Deque?
[Note: Keep an application example for each and every collection individually and go
through the features thoroughly so that you will be able to identify the type of DS to be
used in a particular application when they list some application]
Thread Questions:
1. What are threads?
2. What do you mean by multi-threading?
3. What do you mean by multi-tasking?
4. What do you mean by multi-processing?
5. What is a thread life cycle?
6. What are the advantages of Multi-Threading?
7. What are the different ways to achieve Multi-Threading in java?
8. What is start()?
9. What is run()?
10. Where is start() present?
11. Why do we use start() to invoke run()?
12. List out the difference between Thread and Process.
13. List out the difference between class lock and object lock.
14. What is daemon and non-daemon threads?
15. What are wait(), sleep(), join() and yield()?
16. What is the major differences between notify() and notifyAll()?
17. What is callable interface?
18. What is garbage collection?
19. What is deadlock and how does it occur?
20. What is synchronize()?
21. What is synchronization?
22. What is finalize()?
23. What is synchronized block?
24. What is Thread Scheduler?
25. What is Time Slicing?
26. What are the different properties of Thread? Explain.
27. What will happen if run() is not overridden?
28. Can a thread get it’s own execution time and stack?
29. Default, highest and lowest priority in java.
30. Methods which helps in managing threads.
31. Can we set the ID of a thread?
32. When do we use synchronize method and synchronize block?
33. Which are the default threads in java?