DanChisholm mock exam
HI ALL
here is my question.why the answer is Bird,Cat.??
r2 =r1;// in this statement we are assigning r1 to r2 right???
class GFC301 {
private
String name;
public GFC301(String name) {this.name = name;}
public void setName(String name) {this.name = name;}
public String getName() {return name;}
public static void m1(GFC301 r1, GFC301 r2) {
r1.setName("Bird");
r2 = r1;
}
public static void main (String[] args) {
GFC301 pet1 = new GFC301("Dog");
GFC301 pet2 = new GFC301("Cat");
m1(pet1,pet2);
System.out.println(pet1.getName() + "," + pet2.getName());
}}
What is the result of attempting to compile and run the program?
a. Prints: Dog,Cat
b. Prints: Dog,Bird
c. Prints: Bird,Cat
d. Prints: Bird,Bird
e. Run-time error
f. Compile-time error
g. None of the above