0% found this document useful (0 votes)
9 views4 pages

JAVA_Assignment 1

The document outlines an assignment for a Computer Science course focused on Object Oriented Programming with Java. It includes tasks such as creating a Patient class, finding leaders in an array, merging text files, discussing thread synchronization, and explaining functional interfaces and dependency injection in Spring. The assignment also includes practical programming exercises and theoretical questions related to Java concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

JAVA_Assignment 1

The document outlines an assignment for a Computer Science course focused on Object Oriented Programming with Java. It includes tasks such as creating a Patient class, finding leaders in an array, merging text files, discussing thread synchronization, and explaining functional interfaces and dependency injection in Spring. The assignment also includes practical programming exercises and theoretical questions related to Java concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Department of Computer Science

Even Sem (2024-25)


Assignment 1

Subject: Object Oriented Programming with Java


Code: BCS-403
Semester: IV

Q.1. Create a class Patient with private fields patientId, name, and age. Accenture

 Use setter methods with validation for age (positive value).


 Provide a method to display patient details.

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.

TCS, Wipro, Infosys, Cognizant

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.4. What is thread synchronization? Why is it important in multi-threading? Provide an


example of synchronized methods.

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.

An input string is valid if:


1. Open brackets must be closed by the same type of brackets.
2. Open brackets must be closed in the correct order.

Amazon, Microsoft, Snapdeal, Oracle, Walmart, Adobe

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

You might also like