0% found this document useful (0 votes)
2 views

Java Topics

The document contains a comprehensive list of questions and topics related to Java programming, problem-solving, design, and core Java concepts. It covers various aspects such as HashMap internals, exception handling, CRUD operations in Spring Boot, and data structures. Additionally, it includes problem-solving scenarios, system design questions, and core Java principles like constructors, garbage collection, and access modifiers.

Uploaded by

Rishabh Didwania
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java Topics

The document contains a comprehensive list of questions and topics related to Java programming, problem-solving, design, and core Java concepts. It covers various aspects such as HashMap internals, exception handling, CRUD operations in Spring Boot, and data structures. Additionally, it includes problem-solving scenarios, system design questions, and core Java principles like constructors, garbage collection, and access modifiers.

Uploaded by

Rishabh Didwania
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Java

1. Can you explain the internals of a HashMap?


2. What are the default methods in Java?
3. Can you explain the difference between interfaces and abstract classes? 4. How do you
handle exceptions in controllers?
4. Have you written any CRUD operations in Spring Boot using MySQL?
5. What is the difference between concrete functions in abstraction and default methods in
interfaces?
6. What are Spring Boot components?
7. What is the difference between a singleton in Java and a singleton in Spring?
8. Given a String how will you check if it is a palindrome or not?
9. Merge 2 sorted arrays
10. Difference between set and list and why set does not accept any duplicates while
declaration?
11. Practical use case of overloading and overriding?
12. How to handle the array having duplicate values?
13. There are 2 sorted arrays [1,2,3,4] and [5,6,7,8] to merge them into a resultant sorted array
[1,2,3,4,5,6,7,8].

Problem Solving
1. How would you approach a coding problem that involves encoding and decoding a string?
2. Solve the "Trapping Rain Water" problem (LeetCode).
3. Solve the "Two Sum" problem (LeetCode).
4. As a follow-up, how would you solve the "Two Sum" problem if the array is a rotated sorted
array? Discuss different approaches and their time/space complexities.
5. Can you verbally explain the logic to reverse a string in place without using extra memory?
How would you implement this logic? Please code it out. What are the edge cases for this
scenario? What is the time complexity of your approach?
6. Can you explain the problem of finding the minimum element in a sorted rotated array? How
would you approach solving this problem? Please explain

7. both the brute force and optimal approaches. Can you implement the optimal solution?
What are the edge cases for this scenario?
8. How would you find a specific element in a sorted integer array?
9. Given an array of integers and a number n, how would you find k numbers from the array
whose XOR operation with n is the largest? Can you discuss both the brute force and optimal
approaches?
10. How would you find the median of two sorted arrays in the most optimal way?
11. How would you find the largest sum subtree in a binary tree that contains both positive and
negative numbers? What is the brute force approach? How would you handle the scenario if
the tree is non-binary?
12. Can you implement the node structure for a non-binary tree?
13. How would you find the largest subarray sum in an array containing both positive and
negative integers? Can you explain the brute force approach? How would you optimize this?
14. You are given an integer array arr of size n. Every element of the array is greater than or
equal to 0 and represents an index in the array. Starting from a given startIndex, you follow
the elements of the array as pointers to the next index.
15. Your task is to determine the length of the cycle that occurs when following the indices. If no
cycle is found, return -1.
16. Implement a function in Java that compresses a given string by using the counts of repeated
characters. The function should iterate through the string, count consecutive occurrences of
each character, and return a new compressed string where each character is followed by its
count. If the length of the compressed string is not shorter than the original string, the
function should return the original string.
17. Examples:
18. Input: "aabcccccaaa" Output: "a2b1c5a3"
19. Given an unsorted array of integers, write a Java program to find the smallest missing
positive integer. The smallest missing positive integer is the smallest positive integer (greater
than 0) that does not appear in the array.
20. Input: arr = [3, 4, -1, 1]
21. Output: 2

22. Write a function to find the longest common prefix amongst an array of strings. If there is no
common prefix, return an empty string "".

23. Example 1 :
24. Input : strs = ["flower","flow","flight"] Output : "fl"

25. Example 2 :
26. Input : strs = ["dog","racecar","car"] Output : ""

27. Given a stack, pop out the middle element from stack without using any other data
structure(Time complexity should be O(1) )
28. Eg Input stack {1,2,3,4,5}
29. Final stack {1,2,4,5} -> output is 3
30. Given a linkedlist, return true if there is cycle in linkedlist, return false if there is no cycle.

31. Eg 1->2->3->4->3. output true

32. Three workers A, B, and C are tasked with making toys. Worker A takes 3 days to make one
toy, Worker B takes 2 days to make one toy and Worker C takes 4 days to make one toy. If all
three Workers work together, how many days will it take to produce 10 toys? Explain the
logic behind the approach. Write a code to calculate the number of days required to produce
the 10 toys.
33. Find the index of an element in a rotated sorted array.
34. Find the maximum average marks in student pairs.
35. Merge intervals problem.

36. Design a data structure that supports insert, delete, search, and getRandom in constant
time.
37. Minimum number of candies required to distribute among children based on given
conditions.
38. Find the number of islands in a matrix.
39. Given a string, find the starting index and length of the longest uniform substring. 27. Explain
the best optimized approach for the snowfall trapping problem.
40. Given an array and a value, find if there is a triplet in the array whose sum equals the given
value. Return the triplet if found, else return [-1, -1, -1].

Designing
1. How would you design a system like Spotify?
2. Can you design a database architecture for a student attendance management system? How
would you store attendance data in a database as a blob?
3. What are the advantages and disadvantages of storing data as a blob?
4. How would you design the architecture of an app like Zomato?
5. Given specific functional requirements, how would you design the database schema and
create a low-level design (LLD)?
6. How would you debug an API failure?
7. Design a database solution to effectively store student marks and enrollments data, where
faculty can teach multiple subjects.
8. Design a database for student enrollment in subjects, where each faculty is assigned to a
unique subject and students can enroll in multiple subjects.

Core-Java
1. can constructor be marked as final
2. if constructor marked as final then does it throw compile time or runtime exception?
3. can static method be overridden
4. overloading and overriding
5. difference between throw and throws
6. what is garbage collector
7. abstract class vs interface
8. what is mutable
9. String vs StringBuffer vs StringBuilder
10. lifecycle of a thread
11. what is exception handling
12. checked vs unchecked exceptions with examples
13. access modifiers in java
14. super keyword
15. in context of constructors, methods & variables
16. difference between == and .equals()
17. what are wrapper classes in java
18. their benefits
19. what is toString()
20. what are generics
21. what is try catch block
22. difference between List and Set
23. break and continue
24. Access Modifiers
25. Abstract class vs Interface
26. JVM & byte code explain

You might also like