The following Comparator class is attempting to arrange BankAccount objects by account name, breaking ties by account
Question:
The following Comparator class is attempting to arrange BankAccount objects by account name, breaking ties by account balance. But the code has some syntax errors and some logic errors. What is wrong with the code? How would you correct it?
Transcribed Image Text:
1 import java.util.*; 2 public class AccountComparator extends Comparator { 3. public int compareTo (BankAccount account2) { if (!this.getName ().equals (account2.getName () )) { 4 return this.getName ().compareTo (account2.getName ()); } else { return this.getBalance () account2.getBalance (); 8. 9. 10 }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 55% (9 reviews)
The AccountComparator shown has a few errors line 2 It should implement Comparator rathe...View the full answer
Answered By
Nazrin Ziad
I am a post graduate in Zoology with specialization in Entomology.I also have a Bachelor degree in Education.I posess more than 10 years of teaching as well as tutoring experience.I have done a project on histopathological analysis on alcohol treated liver of Albino Mice.
I can deal with every field under Biology from basic to advanced level.I can also guide you for your project works related to biological subjects other than tutoring.You can also seek my help for cracking competitive exams with biology as one of the subjects.
3.30+
2+ Reviews
10+ Question Solved
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted:
Students also viewed these Computer science questions
-
How would you go about attempting to come up with the probability of a super- event or the probability of a unique- event? What factors would you consider?
-
Problem 2 [20pt] Consider the following Java code: public class BankAccount { public double balance; public BankAccount () ( balance = 0.0; } public void withdraw (double amount) { balance -= amount;...
-
How would you arrange two flat circular coils so that their mutual inductance was? (a) Greatest, (b) Least (without separating them by a great distance)?
-
Identify and summarize the most important models and concepts of employee motivation.
-
A country has two regions, the North and the South, which are identical in all respects except the hourly wage and the number of workers. The demand for labor in each region is: (a) What is the wage...
-
How does international credit management differ from credit management in a single country? Company would any type of international credit management to help their company succeed in other countries....
-
What evidence is protected from disclosure based on a claim of privilege?
-
Calculate financial leverage measures. The following information was available for the year ended December 31, 2013: Earnings before interest and taxes (operating income) ....... $60,000 Interest...
-
GRB Ltd has several product lines with a manager in charge of each product line. The managers are paid a bonus based on the net income generated by their product line. Rubica (the CEO of GRB Ltd) was...
-
A microbiologist argued that there is no such thing as "normal" microbiota in the human body, since the population is dynamic and is constantly changing, depending on diet and external environment....
-
To which complexity class does the following algorithm belong? public static void mystery3 (List list) { for (int i = 0; i < list.size () 1; i += 2) { String first = list.remove (i); list.add (i + 1,...
-
To which complexity class does the following algorithm belong? public static void mystery4 (List list) { for (int i = 0; i < list.size () 1; i += 2) { %3D String first list.get (i); !! list.set (i,...
-
It is May and a trader writes a September call option with a strike price of $20. The stock price is $18, and the option price is $2. Describe the investors cash flows if the option is held until...
-
An employee works for a company that pays $ 1 5 per hour, double time and one - half overtime and has a standard workweek of 4 4 hours. What would be the gross pay for an employee that worked 4 5...
-
You are working on a bid for a 7-year contract. Thus far, you have determined that you will need $159,000 for fixed assets that will be depreciated straight-line to zero over the life of the project...
-
Melun Limited is considering producing a new line of high quality snowboards. The company will incur $62 in variable product costs for each snowboard produced. Fixed manufacturing overhead costs...
-
How do we determine the tax consequences of a disposition of a partnership interest? Please discuss from the buyer's and the seller's perspectives. How is the gain or loss determined?
-
Ivanhoe Company's accounting records reflect the following inventories: Jan. 1, 2022 Dec. 31, 2022 Raw materials inventory $260,000 $320,000 Work in process inventory 160,000 300,000 Finished goods...
-
Marlon and Latoya recently started building a house. They had to pay $300 to the county government for a building permit. Is the $300 payment a tax? Why or why not?
-
Use translations to graph f. f(x) = x-/2 +1
-
What type of relationship cant be stored in a relational database? Why?
-
Identify at least three reasons an organization might analyze historical sales data stored in its database.
-
Which of the following characters can be used in a table name? a. b. ( c. % d. !
-
ed The Alberta Mining and Export Corporation (AMEC) has operations at several locations throughout the province of Alberta in Western Canada. AMEC reports under IFRS as a publicly traded company....
-
261204 5 On April 15, Chemical Cleanup Inc. declared a dividend of $.50 per common share to shareholders of record on May 30, payable on June 30. At the date of declaration, Chemical had 750,000...
-
Given the following information for Maynor Company in 2011, calculate the company's ending inventory, cost of goods sold and gross profit, using the following inventory costing methods, assuming the...
Study smarter with the SolutionInn App