Question: What is the output of the following program.
1 import java.util.*;
2 class Chicken implements Comparable<Chicken> {
3 private int weight;
4 public Chicken(int weight) {this.weight = weight;}
5 public int getWeight() {return weight;}
6 @Override
7 public int compareTo(Chicken c) {
8 return this.weight < c.getWeight() ? 1 : (this.weight == c.getWeight() ? 0: -1);
9 }
10 @Override
11 public String toString() {return weight + "";}
12 }
13 public class Birds{
14 public static void main(String args[]) {
15 List<Chicken> list = new ArrayList<>();
16 list.add(new Chicken(13));list.add(new Chicken(9));list.add(new Chicken(12));
17 Collections.sort(list);
18 System.out.println(list);
19 }}
Choice:
A. [13, 9, 12]
B. [9, 12, 13]
C. [13, 12, 9]
D. output is none of the above options
E. compiler error at line 2
F. compiler error at line 6
G. compiler error at line 10
H. compiler error at other lines