Forums Register Login

Boone's qns

+Pie Number of slices to send: Send
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

+Pie Number of slices to send: Send
About the first question, What Boones says is right.
The following code will compile and run if you call it by
saying "java Test"
class Test {
public static void main(String args[]) {
System.out.println("hello");
}
}
The following code will compile and wont run
class Test {
public static void main() {
System.out.println("hello");
}
}

Note: The top level class could either be public or friendly.

------------------------------------------------------
About the following question,
"You can directly run the garbage collector whenever you want to."
-- I feel he tries to differentiate between "whether you could
run the garbage collector" and "whether it really collects any garbage or not". You might be able to run it when you want to but it collects garbage only when it wants to.
- This is my interpretation. Any takers ?
[This message has been edited by vasansrini (edited July 30, 2000).]
Hang a left on main. Then read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 792 times.
Similar Threads
garbage collection
What's the correct answer
From Boone's Exam Again
another GC (levteck.com)
garbage collection
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:54:47.