Domanda di colloquio di Hexaware Technologies

What is the Java Memory Model (JMM), and why is it important? Answer: JMM defines how threads in Java interact with memory, ensuring proper visibility of shared data and preventing data races. 4. What is the purpose of the volatile keyword in Java? Answer: volatile is used to indicate that a variable's value may be changed by multiple threads simultaneously and ensures visibility of changes. 5. What are lambda expressions in Java, and how are they used? Answer: Lambda expressions provide a concise way to define anonymous functions and are used mainly for functional programming and the Stream API. 6. What is the difference between composition and inheritance in Java? Answer: Composition is a design principle where one class contains an instance of another class, while inheritance is an "is-a" relationship between classes. 7. What is the Java Collections Framework, and why is it important? Answer: The Collections Framework provides classes and interfaces for working with collections of objects, offering reusable data structures and algorithms.