Question 1
When invoking a method with an object argument, ________ is passed.
◦ the contents of the object
◦ the object is copied, then the reference of the copied object
◦ the reference of the object
◦ a copy of the object
Question 2
What is the value of myCount.count displayed?
public class Test {
public static void main(String[] args) {
| Count myCount = new Count(); |
| for (int i=0; i<100; i++) |
| increment(myCount, times); |
| "myCount.count = " + myCount.count); |
| System.out.println("times = "+ times); |
}
public static void increment(Count c, int times) {
}
}
class Count {
int count;
Count(int c) {
}
Count() {
}
}
◦ 98
◦ 101
◦ 100
◦ 99