Sobes.tech

What is garbage collection in Java?

Junior
328

How to write a custom (user-defined) exception in Java?

Junior
328

What variables can lambda expressions in Java access?

Middle
328

What problems can arise from not using transactions in an application?

Middle
328

What are the main professional tasks and achievements you plan to accomplish in the near future?

Junior — Middle+
328

What factors influence data access speed in SQL?

Middle
328

What does Maven provide when building a project?

Junior
328

In what situations is it recommended to use the CopyOnWriteArrayList data structure in a multithreaded environment?

Junior — Middle
327

How to merge two different branches in Git?

Junior
327

Is it possible to implement a functional interface with two abstract methods?

Junior — Middle
327

What makes integration tests less preferable for you?

Junior — Middle
327

Can a value in a column with a FOREIGN KEY constraint be NULL?

Middle
327

What is the difference between map and flatMap operations?

Middle
327

What access modifiers do fields and methods have in default interfaces?

Middle
327

What is the data storage format JSON?

Intern
327

Read the code and highlight errors. /** * A client with a purchased ticket can choose a specific seat for an additional fee. * The base price of seats is determined by tariffs (external service). * For clients with certain tariffs (PREMIUM, ULTRA), a discount is applied at payment. * When booking, an invoice is issued to the client for payment. Payment management is handled by a third-party service. */ @Service public class SeatBookingService { @Autowired private SeatBookingRepository seatBookingRepository; @Autowired private TicketRepository ticketRepository; @Autowired private TariffClient tariffClient; @Autowired private CustomerClient customerClient; @Autowired private PaymentClient paymentClient; /** * Booking. * @param seatCode seat code (e.g., 19A) * @param ticketId ticket ID */ @Transactional public void bookSeat(String seatCode, UUID ticketId) { var ticket = ticketRepository.findById(ticketId); //book var seatBooking = new SeatBooking(seatCode, ticket.get().getFlightId(), ticketId, BookingStatus.BOOKED); seatBookingRepository.save(seatBooking); //find base tariff for the selected seat on the plane var basePrice = tariffClient.getBasePrice(ticket.get().getPlaneModel(), seatCode); //find customer data Long userId = (Long) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); var userData = customerClient.getCustomer(userId); System.out.println("User found " + userData.getFio() + " document number " + userData.getDocument()); var price = basePrice; if (userData.getTariff() == "PREMIUM") { //50% discount price = basePrice * 0.5d; } if (userData.getTariff() == "ULTRA") { //20% discount price = basePrice * 0.8d; } var invoice = new Invoice(price, ticketId, userId); //issue invoice paymentClient.sendInvoice(invoice); System.out.println("Invoice issued"); } @Data @Table("seat_booking") public class SeatBooking { @Column private String seatCode; @Column private UUID flightId; @Column private UUID ticketId; @Column private BookingStatus status; } public enum BookingStatus { BOOKED, PAID; }

327

What is the difference between the dependency and dependencyManagement sections in a Maven configuration file?

Junior — Middle
327

Why are ArrayList and array the fundamental data structures in Java?

Junior
327

What types of table joins have you used in your SQL queries?

Junior — Middle
327
/735