The document discusses several coding questions and scenarios:
1. Splitting an array into chunks of a specified size.
2. Finding common characters between two strings.
3. Whether an Employee class can be used as a key in a HashMap.
4. Finding the highest paid employee in each department from an employee table, discussing pagination and ties.
5. The behavior of calling a synchronized method on two objects of the same class concurrently versus forcing the calls to execute sequentially.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
770 views2 pages
Reading Material-R1 Rocket Java
The document discusses several coding questions and scenarios:
1. Splitting an array into chunks of a specified size.
2. Finding common characters between two strings.
3. Whether an Employee class can be used as a key in a HashMap.
4. Finding the highest paid employee in each department from an employee table, discussing pagination and ties.
5. The behavior of calling a synchronized method on two objects of the same class concurrently versus forcing the calls to execute sequentially.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
Reading Material-
Split an array into chunks with a specified size. Code Template -
https://onlinegdb.com/Ptod_C-qS Ask candidate to fork this code Ensure the candidate fork is given the detailed feedback Ensure the candidate output is copy pasted into the detailed feedback Example - array = [1,2,3,4,5] chunkSize = 1 [1] [2] [3] [4] [5] chunkSize = 2 [1, 2] [3, 4] [5] chunkSize = 3 [1, 2, 3] [4, 5] chunkSize = 4 [1, 2, 3, 4] [5] chunkSize = 5 [1, 2, 3, 4, 5] chunkSize = 6 [1, 2, 3, 4, 5]
Find common characters between strings Code snippet -
https://onlinegdb.com/2_k3E2v6H Ask the candidate to fork the above code The candidates response url must be added in the comments Example: string1 = "abc"; string2 = "dcb"; common characters = "bc";
Can one use an Employee
class as a key in a HashMap? (This is a very important question. If this is not answered satisfactorily, mark the candidate as knowledge gap as best case scenario irrespective of answers to other questions / scenarios)
Employee Table -- Id -- Name
-- Salary -- Department id Find one employee from each department who is getting the highest salary within his department. Discuss further on server side pagination, boundary cases like 2 emp getting the same salary in the same department which is highest etc.
Consider a class A with a
synchronized method class A { public void synchronized m1() {Thread.sleep(5000);} } We create two objects of this class - o1 and o2. We call o1.m1() on one thread and o2.m1() on another thread, at the same time. What will be the behaviour? Follow up with - how will you force these calls to execute one after the other