Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class ComparableDemo ( public void initCobject arr3) // initialize each array element by instantializing Employee class arr[0]- new Employee(Abby, 3000, 1, nul1, f: arr[1]

image text in transcribed
image text in transcribed
public class ComparableDemo ( public void initCobject arr3) // initialize each array element by instantializing Employee class arr[0]- new Employee("Abby", 3000, 1, nul1, f: arr[1] new Employee("John, 2000, 2, CEmployee)arr[0], 'm arr[2] new EmployeeC"Tim, 2008, 2, CEmployee)arr[0], 'm' ar[3neEployeeToy 100, 3, CEmployee arr), This method finds the largest object in the array arr. The largest object is determined on the basis of compareToO method in the Employee class. You have to call compareToO to determine which object is the largest public Object max(Object arra) t public static void main(String args) ComparableDemo demo new ComparableDemoO; // create one-dimensional array of 4 Java Object references. object arr new Object[4]; // populate the array with Employee objects demo.init(arr); //call maxO method to find the largest object in the array Object largest - demo.maxCarr) System.out.printlnC"The Largest object is:1n"+largest); //end of demo class public class ComparableDemo ( public void initCobject arr3) // initialize each array element by instantializing Employee class arr[0]- new Employee("Abby", 3000, 1, nul1, f: arr[1] new Employee("John, 2000, 2, CEmployee)arr[0], 'm arr[2] new EmployeeC"Tim, 2008, 2, CEmployee)arr[0], 'm' ar[3neEployeeToy 100, 3, CEmployee arr), This method finds the largest object in the array arr. The largest object is determined on the basis of compareToO method in the Employee class. You have to call compareToO to determine which object is the largest public Object max(Object arra) t public static void main(String args) ComparableDemo demo new ComparableDemoO; // create one-dimensional array of 4 Java Object references. object arr new Object[4]; // populate the array with Employee objects demo.init(arr); //call maxO method to find the largest object in the array Object largest - demo.maxCarr) System.out.printlnC"The Largest object is:1n"+largest); //end of demo class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

ISBN: 1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

Give the proper name for each molecule. a. N2O b. N2O4 c. N2O5

Answered: 1 week ago

Question

Describe the patterns of business communication.

Answered: 1 week ago

Question

3. Provide two explanations for the effects of mass media

Answered: 1 week ago