OD
(Choose 1 answer)
A. (B.3) (C.4) (C.5) (A.6) (D.7)
B. (D.7) (C.5) (C.4) (B.3) (A.6)
C. (A.6) (B.3) (C.4) (C.5) (D.7)
D. (B.3) (C.5) (D.7) (C.4) (A.6)
import java.util.*;
What is the output of the following program?
class Pen implements Comparable<Pen> {
String color; int price;
Pen(String color, int price) { this.color-color; this.price=price; }
public String toString() { return("("+color+","+price+")"); } t { public int compareTo(Pen x)
x){int k = color.compareTo(x.color);
if(k!=0) return(-k);return(x.price - price);
}
public class Main {
public static void main(String[] args) {
List<Pen> t = new ArrayList<>();t.add(new Pen("B",3));
t.add(new Pen("C",4));t.add(new Pen("D", 7));
t.add(new Pen("C",5));t.add(new Pen("A",6));
Collections.sort(t);
for(Pen x: t) System.out.print(x);System.out.println();