Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 13.6, Problem 13.6.5CP

What is wrong in the following code?

public class Test {

  public static void main(String[] args) {

  Person[] persons = {new Person(3), new Person(4), new Person(1)};

  java.util.Arrays.sort(persons);

  }

}

class Person {

  private int id;

  Person(int id) {

  this.id = id;

  }

}

Blurred answer
Students have asked these similar questions
the code: class HighArray { private long[] a; private int nElems;  public HighArray(int max) {  a = new long[max];  nElems = 0; }  public void insert(long value) {  a[nElems] = value;  nElems++; }  public boolean find(long searchKey) {  int j;  for (j = 0; j < nElems; j++)   if (a[j] == searchKey)    break;  if (j == nElems)   return false;  else   return true; }  public long getMax() {  if (nElems == 0)   return 01;  else {   long max = a[0];   for (int i = 1; i < nElems; i++) {    if (a[i] > max)     max = a[i];   }   return max;  } }  public boolean delete(long value) {  int j;  for (j = 0; j < nElems; j++)   if (value == a[j])    break;  if (j == nElems)   return false;  else {   for (int k = j; k < nElems; k++)    a[k] = a[k + 1];   nElems--;   return true;  } }  public void display() {  for (int j = 0; j < nElems; j++)   System.out.print(a[j] + " ");  System.out.println(""); }} public class HighArrayApp {  public static void main(String[] args) {  int maxSize =…
public class test{     private static final int MAX = 100;     private int[] sco;     public test(int[] sco){         this.sco = sco;     }     private int comAvg() throws IllegalArgumentException{         int sum = 0;         for (int i = 0; i < sco.length; i++){             int sc = sco[i];             if (sc < 0 || sc > MAX){                 throw new IllegalArgumentException("Score (" + sc + ") is not in the range 0-" + MAX);             }             sum += sco[i];         }         int av = sum / sco.length;         return av;     }     public static void main(String[] args){         test test = new test(new int[] { 50, 70, 81 });         try{             int avgSc = test.comAvg();             char letG;             if (avgSc < 60) letG = 'F';             else if (avgSc < 70) letG = 'D';             else if (avgSc < 80) letG = 'C';             else if (avgSc < 90) letG = 'B';             else letG = 'A';             System.out.println("\nAVG Score is " +…
public class Number {   private int num;      public Number(int n) {      num = n;   }    /* Type your code here */      public int getNum() {      return num;   }      public void setNum(int n) {      num = n;   }    public static void main(String [] args) {      Number yourNum = new Number(723);      System.out.print(yourNum);   }}

Chapter 13 Solutions

Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)

Ch. 13.4 - How do you create a Calendar object for the...Ch. 13.4 - For a Calendar object c, how do you get its year,...Ch. 13.5 - Prob. 13.5.1CPCh. 13.5 - Prob. 13.5.2CPCh. 13.5 - Prob. 13.5.3CPCh. 13.5 - Prob. 13.5.4CPCh. 13.6 - Prob. 13.6.1CPCh. 13.6 - Prob. 13.6.2CPCh. 13.6 - Can the following code be compiled? Why? Integer...Ch. 13.6 - Prob. 13.6.4CPCh. 13.6 - What is wrong in the following code? public class...Ch. 13.6 - Prob. 13.6.6CPCh. 13.6 - Listing 13.5 has an error. If you add list.add...Ch. 13.7 - Can a class invoke the super.clone() when...Ch. 13.7 - Prob. 13.7.2CPCh. 13.7 - Show the output of the following code:...Ch. 13.7 - Prob. 13.7.4CPCh. 13.7 - What is wrong in the following code? public class...Ch. 13.7 - Show the output of the following code: public...Ch. 13.8 - Prob. 13.8.1CPCh. 13.8 - Prob. 13.8.2CPCh. 13.8 - Prob. 13.8.3CPCh. 13.9 - Show the output of the following code: Rational r1...Ch. 13.9 - Prob. 13.9.2CPCh. 13.9 - Prob. 13.9.3CPCh. 13.9 - Simplify the code in lines 8285 in Listing 13.13...Ch. 13.9 - Prob. 13.9.5CPCh. 13.9 - The preceding question shows a bug in the toString...Ch. 13.10 - Describe class-design guidelines.Ch. 13 - (Triangle class) Design a new Triangle class that...Ch. 13 - (Shuffle ArrayList) Write the following method...Ch. 13 - (Sort ArrayList) Write the following method that...Ch. 13 - (Display calendars) Rewrite the PrintCalendar...Ch. 13 - (Enable GeometricObject comparable) Modify the...Ch. 13 - Prob. 13.6PECh. 13 - (The Colorable interface) Design an interface...Ch. 13 - (Revise the MyStack class) Rewrite the MyStack...Ch. 13 - Prob. 13.9PECh. 13 - Prob. 13.10PECh. 13 - (The Octagon class) Write a class named Octagon...Ch. 13 - Prob. 13.12PECh. 13 - Prob. 13.13PECh. 13 - (Demonstrate the benefits of encapsulation)...Ch. 13 - Prob. 13.15PECh. 13 - (Math: The Complex class) A complex number is a...Ch. 13 - (Use the Rational class) Write a program that...Ch. 13 - (Convert decimals to fractious) Write a program...Ch. 13 - (Algebra: solve quadratic equations) Rewrite...Ch. 13 - (Algebra: vertex form equations) The equation of a...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License