Tech Interview Qs
Tech Interview Qs
JAVA
1. **What is Java?**
- Java is a high-level, object-oriented programming language designed to have as few
implementation dependencies as possible.
10. **How do ArrayList, LinkedList, HashMap, HashSet, TreeMap, and TreeSet di er?**
- `ArrayList`: Resizable array implementation.
- `LinkedList`: Doubly linked list implementation.
- `HashMap`: Hash table-based implementation.
- `HashSet`: Hash table-based set.
- `TreeMap`: Red-Black tree-based map.
- `TreeSet`: Red-Black tree-based set.
12. **What are the di erences between fail-fast and fail-safe iterators?**
- Fail-fast: Immediately throws `ConcurrentModi cationException` if the collection is
modi ed.
- Fail-safe: Works on a copy of the collection, allowing modi cations without exception.
18. **What are threads, and how are they di erent from processes?**
- Threads are the smallest unit of execution within a process, while processes are
instances of programs that can contain multiple threads.
20. **What are thread pools, and how do you create them using the ExecutorService?**
- A thread pool reuses a xed number of threads to execute tasks, created using
`Executors.newFixedThreadPool()`, `newCachedThreadPool()`, etc.
28. **What are streams in Java 8, and how do you use them?**
- Streams: Enable functional-style operations on sequences of elements.
- Used for processing collections through a pipeline of operations like ` lter()`, `map()`,
and `collect()`.
29. **How do Optional and the new date/time API work in Java 8?**
- `Optional`: Container object used to avoid null checks.
- New date/time API: Provides a comprehensive date/time handling with `LocalDate`,
`LocalTime`, `ZonedDateTime`, etc.
30. **What are the Singleton, Factory, Builder, and Observer design patterns?**
- Singleton: Ensures a class has only one instance.
- Factory: Creates objects without specifying the exact class.
- Builder: Simpli es object creation with complex constructors.
- Observer: Allows an object to notify observers of state changes.
39. **How does the Java Stream API work, and what are its bene ts?**
- Provides a functional approach to processing sequences of elements, o ering
bene ts like parallel processing and concise code.
7. **What is the time complexity of basic list operations like `append`, `pop`, etc.?**
- `append`: O(1), `pop`: O(1) for the last element, O(n) for the rst element.
9. **Explain the concept of REST APIs. How do you create one in Python?**
- REST APIs use HTTP requests for CRUD operations. Created using frameworks like
Flask or Django REST framework.
10. **What is the di erence between `__init__` and `__new__` methods in Python?**
- `__init__`: Initializes a new instance of a class. `__new__`: Creates a new instance of a
class.
ffi
ff
ff
fi
ff
fi
fi
fi
11. **How do you perform data visualization in Python? Name some libraries.**
- Using libraries like Matplotlib, Seaborn, Plotly, and Bokeh.
15. **Explain the concept of a linked list. How do you implement it in Python?**
- A data structure consisting of nodes, each containing data and a reference to the next
node. Implemented using classes.
16. **What are Python's built-in libraries for data analysis and scienti c computing?**
- NumPy, Pandas, SciPy, and Matplotlib.
33. **How does C++ handle memory management di erently than Java?**
- C++ requires explicit memory management using `new` and `delete`, while Java uses
automatic garbage collection.