PRO192_-_S6_-_FA_2023_-_FE_1038.webp
V

PRO192_-_S6_-_FA_2023_-_FE_1038.webp

(Choose 1 answer)
import java.util.*;
What is the output of the following program?
A. (B.3) (C.4) (C.5) (A.6)(D.7)
String color; int price;
class Pen implements Comparable<Pen> {
Pen(String color, int price) { this.color-color; this.price=price; } public String toString() { return("("+color+","+price+") "); }
B. (A.6) (B.3) (C.4) (C.5)(D.7)
public int compareTo(Pen x) { int k = color.compareT To(x.color);
}
if(k!=0) return(-k);
C. (B.3) (C.5) (D.7) (C.4)(A.6)
return(x.price - price);
D. (D.7) (C.5) (C.4) (B.3)(A.6)
}
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();


Exit 26

Thông tin

Category
PRO192
Thêm bởi
vanthang97
Ngày thêm
Lượt xem
4,199
Lượt bình luận
20
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
PRO192_-_S6_-_FA_2023_-_FE_1038.webp
File size
68.1 KB
Dimensions
1542px x 690px

Share this media

Back
Bên trên Bottom