JAVA_Assignment 1
JAVA_Assignment 1
Q.1. Create a class Patient with private fields patientId, name, and age. Accenture
Q.2. Array Leaders: You are given an array array of positive integers. Your task is to find all the
leaders in the array. An element is considered a leader if it is greater than or equal to all elements
to its right. The rightmost element is always a leader.
Example:
Input: arr = [16, 17, 4, 3, 5, 2]
Output: [17, 5, 2]
Explanation: Note that there is nothing greater on the right side of 17, 5 and, 2.
Q.3. Write a program to merge the contents of two text files into a third file. Accenture
Q.5. What is a functional interface in Java, and how does it relate to lambda expressions?
Provide an example of defining and using a custom functional interface with a lambda
expression.
Q.6. Write a program using Predicate to check if a number is greater than 10 using a lambda
expression. Infosys
Q.7. How does HashMap differ from Hashtable in Java? Discuss thread safety, performance, and
synchronization aspects.
Q.8. Given a string s, composed of different combinations of '(' , ')', '{', '}', '[', ']', verify the
validity of the arrangement.
Example:
Input: s = "[{()}]"
Output: true
Explanation: All the brackets are well-formed.
Q.9. Explain the concept of Inversion of Control (IoC) in Spring and how it helps in managing
dependencies in a Java application. Provide an example of XML-based and annotation-based
configuration for IoC.
Q.10. How does Spring’s @Autowired annotation work in dependency injection? What are the
different modes of autowiring in Spring, and how do they impact bean injection?
Infosys