Cognizant Java Technical Interview - Questions &
Answers
1. What are the main features of Java?
Java is platform-independent, object-oriented, secure, simple, multithreaded, portable, and has
automatic garbage collection.
2. Why is Java not 100% Object-Oriented?
Because it supports primitive data types (int, char, etc.) which are not objects. Wrapper classes are
used to treat them as objects.
3. Difference between JDK, JRE, and JVM?
JDK: Java Development Kit (contains tools to develop applications). JRE: Java Runtime
Environment (provides libraries for execution). JVM: Java Virtual Machine (executes bytecode).
4. Explain OOPs concepts in Java.
Encapsulation, Inheritance, Polymorphism, and Abstraction are the four pillars of OOP.
5. What is the difference between Overloading and Overriding?
Overloading: Same method name but different parameters (compile-time polymorphism).
Overriding: Redefining parent method in child class (runtime polymorphism).
6. What is Exception Handling in Java?
It is a mechanism to handle runtime errors. Keywords: try, catch, throw, throws, finally.
7. Difference between Checked and Unchecked Exceptions?
Checked: Known at compile time (IOException, SQLException). Unchecked: Known at runtime
(NullPointerException, ArithmeticException).
8. What are Collections in Java?
Collections framework provides data structures like List, Set, Map, Queue for storing and
manipulating groups of objects.
9. Difference between ArrayList and LinkedList?
ArrayList: Uses dynamic array, fast for searching, slower for insertion/deletion. LinkedList: Uses
doubly linked list, faster for insertion/deletion, slower for searching.
10. What is multithreading in Java?
It is the ability of Java to execute multiple threads simultaneously. Threads can be created by
extending Thread class or implementing Runnable interface.
11. Difference between ‘==’ and ‘.equals()’?
== compares references (memory address). equals() compares object content.
12. What is the use of the final keyword?
final variable: constant, final method: cannot be overridden, final class: cannot be inherited.
13. Explain the concept of Garbage Collection.
Automatic memory management in Java. The Garbage Collector removes unused objects to free
up memory.
14. What is Spring Framework?
Spring is an open-source framework for building enterprise applications. Provides features like
Dependency Injection, MVC, Data Access, Security, etc.
15. What is Hibernate?
Hibernate is an ORM (Object Relational Mapping) tool used to map Java objects to database tables
and vice versa.