If you were designing a GC, what approaches to garbage collection do you know besides traversing the reachability graph?
Java
What is a deadlock? How does it differ from a race condition? How to avoid deadlock, including when it is impossible to determine the order of lock acquisition in advance?
Implement RecommenderService with methods getTop(User user, int limit) and addDocument(Document document), using in-memory storage.
How much does a pointer weigh? What is it?
Why are stacks and heaps needed? What is the difference?
Why did the test fail with NullPointerException and how to fix it?
What is heap?
How does object deletion occur in Java heap? Tell me about Garbage Collector.
Compare the performance of the following code snippets that copy elements from an Integer array to an int array and vice versa, including the case where new Integer objects are created from int values: ```java int SIZE = 1000000; int[] x = new int[SIZE]; Integer[] y = new Integer[SIZE]; for (;;) { for (int i = 0; i < SIZE; ++i) { x[i] = y[i]; } } ``` ```java int SIZE = 1000000; int[] x = new int[SIZE]; Integer[] y = new Integer[SIZE]; for (;;) { for (int i = 0; i < SIZE; ++i) { y[i] = x[i]; } } ``` ```java int SIZE = 1000000; int[] x = new int[SIZE]; Integer[] y = new Integer[SIZE]; for (;;) { for (int i = 0; i < SIZE; ++i) { y[i] = new Integer(x[i]); } } ``` Analyze and explain the differences in performance and behavior among these approaches.
Какой принцип SOLID нарушен в текущей реализации, где сервис жёстко завязан на конкретной реализации хранилища (ArrayList)?
What methods of inter-process communication (IPC) do you know at the Unix operating system interface level?
int SIZE = 1000000; int[] x = new int[SIZE]; Integer[] y = new Integer[SIZE]; for (;;) { for (int i = 0; i < SIZE; ++i) { y[i] = new Integer(x[i]); } }
What problem arises in a production environment with multi-threaded access to a service (several REST requests in parallel)?
How does a primitive appear in the stack, and how in the heap?
Why is synchronized needed? What would you use to implement a thread-safe counter instead of synchronized?
/ ** * Find two numbers in an array whose sum equals a given number * <p> * Write a function that takes an array of positive unordered numbers as the first argument * and a positive number as the second argument. The function should return true if * there are 2 numbers in the array that sum up to the second argument. * <p> * Input: ([10, 15, 3, 7], 17) * Output: true * /
What are the disadvantages of the current approach of sorting the entire list each time getTop is called?
Decode the abbreviation ACID and explain each property.
What is the fork system call in Unix-like operating systems?
What is the difference between using 'let' and 'also' keywords in programming?