Question: Exercise 3 . 1 . What happens when you run the following code? Choose all that apply. ` ` ` public class Duck { private
Exercise What happens when you run the following code? Choose all that apply.
public class Duck
private String name;
public DuckString name this.name name;
public static void mainString args
List ducks new ArrayList;
ducks.addnew DuckQuack;
ducks.addnew DuckPuddles;
Collections.sortducks; sort by name
System.out.printlnducks;
public String toString return name;
public int compareToDuck d
return name.compareTodname; call String's compareTo
a The code does not compile.
b The error is on line
c The errors are on lines and
d The errors are on lines and
e This code runs just fine. It prints Puddles Quack
f This code runs just fine. It prints Quack Puddles
g The error is on line
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
