Win a copy of Terraform in Action this week in the Cloud forum!

Minakshi

Greenhorn
+ Follow
since Nov 28, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Minakshi

QUESTION : 21
What is the output of the following program
1. public class Test {
2. private int i = giveMeJ();
3. private int j = 10;
4.
5. private int giveMeJ() {
6. return j;
7. }
8.
9. public static void main(String args[]) {
10. System.out.println((new AQuestion()).i);
11. }
12. }
Select one correct answer
a. Compile error complaining about access restriction of private variables of AQuestion
b. Compile error complaining about forward referencing.
c. No compile error. The output is 0
d. No compilation error - The output is 10
==========================================================================================
The given answer is 'c'
Please explain this someone!
========================================================================
Read the following snippet carefully
1. public synchronized void someMethod() {
2. //lots of code
3. try {
4. Thread.sleep(500);
5. } catch(InterruptedException e) {
6. //do some things here.
7. }
8. //more and more code here
9. }
Select all correct answers
a. The code causes compilation error - sleep cannot be called inside synchronous methods
b. The thread sleeps for atleast 500 milliseconds in this method if not interrupted.
c. When the thread "goes to sleep" it releases the lock on the object.
d. The "sleeping" threads always have the lock on the object.
=======================================================================
The answer is given as 'c' and 'd' which seems contradictory to me. I think it should be 'b' and 'c'
Please clarify.
20 years ago
You've done a fine job. Congratulations.
I'm also preparing for the certification exam. Please send me your JLS notes. It'll be very kind of you. Thanks.
Minakshi
minakshijain@yahoo.com
21 years ago
Just joined this group today.
Thats a real winner!
CONGRATS!!!
21 years ago