0% found this document useful (0 votes)
6 views1 page

Java Programming Challenges: Syntax & OOP

The document outlines three programming tasks: a Java program to find the second largest number in an integer array with O(n) complexity, a class design for a Library Book with private attributes and public methods, and a method for division that handles exceptions for zero divisors. Each task includes specific requirements and features to be implemented. The focus is on basic syntax, data structures, object-oriented programming, and exception handling.

Uploaded by

Reddy7278
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)
6 views1 page

Java Programming Challenges: Syntax & OOP

The document outlines three programming tasks: a Java program to find the second largest number in an integer array with O(n) complexity, a class design for a Library Book with private attributes and public methods, and a method for division that handles exceptions for zero divisors. Each task includes specific requirements and features to be implemented. The focus is on basic syntax, data structures, object-oriented programming, and exception handling.

Uploaded by

Reddy7278
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

Question 1: Basic Syntax and Data Structures

Problem Statement: Write a Java program to find the second largest number in an array of
integers.

Requirements:

 The program should handle arrays of different lengths, including edge cases like
arrays with less than two elements.
 Optimize the program to run in O(n) time complexity.

___________________________________________________________________

Question 2: Object-Oriented Programming

Problem Statement: Design a class called Library Book to represent a book in a library
system. The class should have the following features:

 Private attributes for the book's title, author, and ISBN.


 A constructor to initialize these attributes.
 Public getter methods for each attribute.
 A method called display Info that prints out the book's details in a user-friendly
format.

_____________________________________________________________________

Question 3: Exception Handling

Problem Statement: Write a method called divide that takes two integers and returns their
quotient. If the divisor is zero, the method should throw an Illegal Argument Exception
with an appropriate error message.

You might also like