Default methods in Java 8 interface REST API internal working HashMap internal working Java 17 features Exception handling in Java Find the first non-repeating character in a string Find the top 3 highest salaries from a table (SQL) Reverse a list in round 2 only
Anonymous
. Default methods in Java 8 interface: Java 8 introduced default methods in interfaces to allow adding method implementations without breaking existing classes. This enables backward compatibility and supports multiple inheritance of behavior. 2. REST API internal working: REST APIs use HTTP methods (GET, POST, PUT, DELETE) to perform CRUD operations. Each resource is accessed via a unique URI. They follow a stateless architecture where the server does not store client context. 3. HashMap internal working: HashMap stores key-value pairs in an array of buckets. It uses hashCode() to determine the bucket index and equals() to handle key collisions. If multiple keys hash to the same bucket, it uses a linked list (or a tree for large chains from Java 8 onward). 4. Java 17 features: Key features of Java 17 include sealed classes, pattern matching for switch, new rendering pipeline for macOS, context-specific deserialization filters, and enhanced pseudo-random number generators. 5. Exception handling in Java: Use try-catch blocks to handle exceptions. The try block contains code that might throw exceptions. The catch block handles specific exceptions, and the finally block (if present) executes regardless of exception occurrence. 6. Find the first non-repeating character in a string: Use a LinkedHashMap to count occurrences while preserving order. Iterate the map to find the first character with value 1. 7. Find top 3 highest salaries from a table (SQL): SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 3; 8. Reverse a list (Java): for (int i = list.size() - 1; i >= 0; i--) { System.out.print(list.get(i)); }
Check out your Company Bowl for anonymous work chats.