Java & Aptitude Questions with Answers
1. Java Null Pointer Exception Question
Answer: exception
2. Big O for sum 1+2+...+n
Answer: O(n)
3. Java Method Overriding
Answer: B
4. Max-Heap Priority Queue
Answer: 10, 8, 7, 3, 2, 1, 5
5. Make Utility Algorithm
Answer: Topological Sorting
6. Train Problem (Rampur-Sitapur)
Answer: Both trains are equidistant
7. Candidate Key Problem
Answer: {A, B, D}
8. 3NF Database
Answer: Transitive Dependency
9. AVL Tree Rebalancing Time Complexity
Answer: O(log n)
10. Linear Data Structure
Answer: Array
11. Race Problem
Answer: Harinder followed by Maninder
12. Stack & Queue Operations
Answer: C
13. HashMap Duplicate Key
Answer: It will replace the old mapping
14. Join Operation Maximum Rows
Answer: Full Outer Join
15. Hash Table with Closed Hashing
Answer: 0:1, 1:8, 2:10, 3:_, 4:_, 5:_, 6:3
16. Merge Sort Average Case Time Complexity
Answer: O(n log n)
17. Java Constructor Return Type
Answer: Constructors have no return type
18. Sorting Identical Elements
Answer: Insertion Sort
19. Java Execution Order
Answer: Static Block → Instance Block → Constructor → Method
20. Family Granddaughter
Answer: Granddaughter is a student
21. Java Polymorphism
Answer: CMe
22. Constructor Return Type
Answer: None
23. Cycle Detection in Directed Graph
Answer: Edge from currently being visited node to an ancestor
24. Java Thread Output
Answer: A C B