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: 63% (11 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...
-
Transcribed image text: 9:13 LTE Done 7 of 7 QUESTION WA AUDION QUESTION 23 = w the tons of a coin comes down heads, you win two dollars. If it comes down tails, you lose fifty cents. How much would...
-
(Treasury Stock Transactions and Presentation) Andruw Jones Company had the following stockholders equity as of January 1, 2007. During 2007, the following transactions occurred. Feb. 1 Jones...
-
Joey Cuono started his own consulting firm, Cuono Company SpA on June 1, 2017. The trial balance at June 30 is shown below. In addition to those accounts listed on the trial balance, the chart of...
-
Answer B The following condensed balance sheet is for the partnership of Miller, Tyson, and Watson, who share profits and losses in the ratio of 6:2:2, respectively Cash Other assets $ 54,000 167,000...
-
Because an earlier visit with the accounting instructor [see Case 5-3, Joan Holtz (A)] had cleared up some puzzling matters, Joan Holtz decided to prepare a new list of problems as a basis for a...
-
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,...
-
True Or False The primary question in a negligence cause of action based on lack of informed consent is whether the risks that are not disclosed were material risks.
-
Because her insurance agency is in a lakeside community, Adriana always asks her homeowners clients what boating activities they engage in, and she is sure to add the Watercraft endorsement...
-
1. Among all assumptions in CVP analysis, which one do you think is the most critical? Explain. 2. How will you change the cost-volume-profit analysis if the assumption (you identify in the previous...
-
Construct a confidence interval for p-P2 at the given level of confidence. x =26, n =229, x2 = 31, n = 302, 95% confidence The researchers are % confident the difference between the two population...
-
AP 9-2 (Moving Expenses) In May of the current year, following a dispute with her immediate superior, Ms. Elaine Fox resigned from her job in Halifax and began to look for other employment. She was...
-
Minimize the number of states in the following DFA: A b b a a a b b b E B a a
-
Design an algorithm for testing whether a given string is a palindrome. (Recall that a palindrome is a word that is the same forward and backward. For example, the words wow and racecar are...
-
Solve each equation. x 3 - 6x 2 = -8x
-
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. !
-
Oct. 31: Paid salaries, $45,000 ( 75% selling, 25% administrtive). Data table Data table them to retail stores. The company has three inventory items: and floor lamps. RLC uses a perpetual inventory...
-
question 1- You borrow a simple loan of SR 500,000, interest rate is 20%, it matures in one year. what's the yied to maturity? question 2- calculate_i for One-Year Discount Bond with price(p) =...
-
Taste of Muscat is a reputed chain of restaurants operating in Oman. Assume You are working as a management accountant for this restaurant chain which is specialized in all types of Arabic food. Your...
Study smarter with the SolutionInn App