Can you explain what Spring is and what it is used for in Java development?
Java
Have you had experience using multithreading in Java projects?
public class Accumulator { private Map<String, Object> data = new HashMap<>(); // current data set private List<Map<String, Object>> dataList = new ArrayList<>(); // batch of data private Map<Instant, String> responses = new HashMap<>(); // responses from the server receiving data private int dataId; /** * Adds a field field with value to the set */ public void add(String field, String value) { data.put(field, value); } /** * Returns the value by the field name */ public <T> T get(String field) { return (T) data.get(field); } /** * Returns responses from the server receiving data */ public String getResponses() { String out = ""; for (String resp : responses.values()) { out += "; " + resp; } return out; } /** * Completes the current data set and sends it to the batch */ public synchronized void push() { dataList.add(data); if (dataList.size() == 100) { send(); dataList.clear(); } data = new HashMap<>(); data.put("id", dataId++); } /** * Sends the batch to the data receiving server */ private void send() { RestTemplate restTemplate = new RestTemplate(); HttpEntity<List<Map<String, Object>>> request = new HttpEntity<>(dataList); String url = "localhost:20808/msg/incoming"; ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, request, String.class); responses.put(Instant.now(), response.getBody()); } }
public static void main(String args[]) { checkMap(new HashMap<>()); checkMap(new LinkedHashMap<>()); checkMap(new TreeMap<>()); } private static void checkMap(Map<Person, String> map) { System.out.println("Checking " + map.getClass()); Person ivan = new Person("Иван"); Person peter = new Person("Пётр"); Person maria1 = new Person("Мария"); Person maria2 = new Person("Мария"); map.put(ivan, ivan.name); map.put(peter, peter.name); map.put(maria1, maria1.name); map.put(maria2, maria2.name); // iterate and println for (Map.Entry<Person, String> entry : map.entrySet()) { System.out.println(entry); } // maria1.setName("Анна-Мария"); // maria2.setName("Анна-Мария"); System.out.println(map.get(maria1)); System.out.println(map.get(maria2)); System.out.println("==================================="); }
Can you list the main methods of the ExecutorService interface and explain their purpose?
How do you assess your level — mid or senior?
В чем разница между WHERE и HAVING?
//Given two beans. An exception occurred during the third iteration in method m1. How many records will be in the database? public class BeanA() { private BeanB b; @Transactional public void m1(List<Integer> list) { for (Integer i : list) { b.m2(i); } } } public class BeanB() { @Transactional public void m2(Integer i) { // Add record to table } }
What collection should be used to store the history of visited pages without duplicates while preserving order?
If we use POST, but HTTP (not HTTPS) — what then?
What is a memory leak in Java? What algorithm is used to find it?
What is the difference between @Bean and @Service annotations in Spring Framework?
What does the reduce method do?
What skills or knowledge are you aiming to develop in the near future?
How do you implement object comparison methods and hash code calculations in your code?
Which collection would you use to implement a stack data structure?
Under what conditions will the finally block not be called during program execution?
How were your development processes structured at your previous workplace? How did tasks come in?
What is the limitation on the number of Stream applications in Java?
How to subscribe to Flux/Mono in reactive programming? What options are available?