Assume the following tester code (see Figure 1) is in the main class that produces the output shown in Figure 2 below. Provide two static generic methods that are called by the main method shown below: • isMin(.) generic method that takes an object value and an array of objects; the method checks and returns whether the given object equals to the smallest element value of the passed Array. Hint: use Comparable interface of the standard Java library, where Comparable interface has a single method called "compareTo". • present(..) generic method to print the passed Array elements separated by "| " as shown in the sample output run below (see Figure 2) Tester Code (Figure 1): public static void main(String[] args) { Integer[] ages = {16, 70 , 15, 40, 3, 22}; Double [] scores = {85.7, 38.9, 72.75, 64.9, 15.3, 99.6}; String[] persons = { "Hamed", "zinab", "Amal", "Naif", "Khalid"}; //call generic method isMin to return answer

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Assume the following tester code (see Figure 1) is in the main class that produces the output shown in Figure 2 below. Provide two static
generic methods that are called by the main method shown below:
• isMin(.) generic method that takes an object value and an array of objects; the method checks and returns whether the given object
equals to the smallest element value of the passed Array. Hint: use Comparable interface of the standard Java library, where
Comparable interface has a single method called "compareTo".
• present(.) generic method to print the passed Array elements separated by "| " as shown in the sample output run below (see Figure 2)
Tester Code (Figure 1):
public static void main(String[] args) {
Integer[] ages =
{16, 70 , 15, 40, 3, 22};
Double [] scores = {85.7, 38.9, 72.75, 64.9, 15.3, 99.6};
String [] persons = { "Hamed", "Zinab", "Amal", "Naif", "Khalid"};
//call generic method isMin to return answer
System.out.println("The youngest person is 3 years old? "
+ isMin(ages,3) );
System.out.print("Ages: ");
present(ages);
//call generic method to display array as shown in output sample
System.out.println("-
-");
System.out.println("The lowest score is 15.5? " +
isMin(scores,15.5) );
System.out.print("Scores: ");
present(scores);
System.out.println("
//Notice names are not sorted by considered alphabatically
");
System.out.println("The first person in the list is Amal?
+ isMin(persons,"Amal")
System.out.print("Persons: " );
present (persons);
System.out.println("
} //end main
");
Sample output run (Figure 2):
run:
The youngest person is 3 years old? true
Ages: 16| 70| 15| 40| 3| 22
The lowest score is 15.5? false
Scores: 85.7| 38.9| 72.75| 64.9| 15.3| 99.6
The first person in the list is Amal? true
Persons: Hamed| Zinab| Amal| Naif| Khalid
Transcribed Image Text:Assume the following tester code (see Figure 1) is in the main class that produces the output shown in Figure 2 below. Provide two static generic methods that are called by the main method shown below: • isMin(.) generic method that takes an object value and an array of objects; the method checks and returns whether the given object equals to the smallest element value of the passed Array. Hint: use Comparable interface of the standard Java library, where Comparable interface has a single method called "compareTo". • present(.) generic method to print the passed Array elements separated by "| " as shown in the sample output run below (see Figure 2) Tester Code (Figure 1): public static void main(String[] args) { Integer[] ages = {16, 70 , 15, 40, 3, 22}; Double [] scores = {85.7, 38.9, 72.75, 64.9, 15.3, 99.6}; String [] persons = { "Hamed", "Zinab", "Amal", "Naif", "Khalid"}; //call generic method isMin to return answer System.out.println("The youngest person is 3 years old? " + isMin(ages,3) ); System.out.print("Ages: "); present(ages); //call generic method to display array as shown in output sample System.out.println("- -"); System.out.println("The lowest score is 15.5? " + isMin(scores,15.5) ); System.out.print("Scores: "); present(scores); System.out.println(" //Notice names are not sorted by considered alphabatically "); System.out.println("The first person in the list is Amal? + isMin(persons,"Amal") System.out.print("Persons: " ); present (persons); System.out.println(" } //end main "); Sample output run (Figure 2): run: The youngest person is 3 years old? true Ages: 16| 70| 15| 40| 3| 22 The lowest score is 15.5? false Scores: 85.7| 38.9| 72.75| 64.9| 15.3| 99.6 The first person in the list is Amal? true Persons: Hamed| Zinab| Amal| Naif| Khalid
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Passing Array as Argument
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education