Hi, I just took the Boone mock exam. I am just a little doubful about the following qns. Can anybody help me?
1. What will happen when you attempt to compile and run the following program by passing the
Test class to the
Java interpreter?
class Test {
public static void main() {
System.out.println("hello");
}
}
Select the one right answer.
1. The program does not compile because main() is not defined correctly.
2. The program compiles but when you try to run the interpreter complains that it cannot find the main() method it needs to run.
3. The program compiles but you cannot run it because the class is not declared as public.
4. The program compiles and runs without an error but does not display anything in the standard output.
5. The program compiles and displays "hello" in the standard output when you run it.
The answer given is 2, but I think the answer should be 3 (and also 2, if multiple answers are allowed).
Question 65: Which statements about garbage collection are true?
Select all valid answers.
a. You can directly free the memory allocated by an object.
b. You can directly run the garbage collector whenever you want to.
c. The garbage collector informs your object when it is about to be garbage collected.
d. The garbage collector reclaims an object�s memory as soon as it becomes a candidate for garbage collection.
e. The garbage collector runs in low-memory situations.
My answer is c, e, but the answer given is b,c,e. I don't think b is correct 'coz you can't run the garbage collector, you can only request it to be run. Any suggestions?
Thanks,
Aman