Jane W pemberley

Greenhorn
+ Follow
since Apr 26, 2005
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 Jane W pemberley

Thank You All,
For ur wishes.Got hold of HF Servlets & JSP. Wish me "All the best".
Thanks & Regards
Jane
17 years ago
Hi all,
Passed SCJP with 91% today.Thanks to U all.Thank you so much for ur help and encouragement ... This is really a great group.
Thanking U once again,
Jane
17 years ago
I think,
null,false,true are reserved words not keywords.
and all keywords are reserved.

Hope u can notice the difference
rgrds
Jane
Hi,
We all know that do .. while loop executes its body atleast once.Then,It will go, check the condition ,based on the result, it will execute or exit the loop.
In this particular case , after finding the continue; statement it will decide not to execute the rest of the loop (ie. statements after the continue; statement) and will go to test the condition in the conditional part of the loop (while(condition))...increment the value of the var j and evaluate the logical expression.Here in this case there are no statements after the continue statement , so this continue; is just redundant.

So after executing the loop for 5 times for j=0,1,2,3,4 j value will become 5 , condition fails, loop exits ,printing the final value of J as 5.

Hope this helps
rgrds
Jane
This is from K & B's book:

Referencing the Inner or Outer Instance from Within the Inner Class:
Within an inner class code, the this reference refers to the instance of the inner class, as you�d probably expect, since this always refers to the currently-executing object. But what if the inner class code wants an explicit reference to the outer class instance the inner instance is tied to? In other words, how do you reference the �outer this�? Although normally the inner class code doesn�t need a reference to the outer class,
since it already has an implicit one it�s using to access the members of the outer class, it would need a reference to the outer class if it needed to pass that reference to some other code as follows:

class MyInner {
public void seeOuter() {
System.out.println("Outer x is " + x);
System.out.println("Inner class ref is " + this);
System.out.println("Outer class ref is " + MyOuter.this);
}
}

If we run the complete code as follows:
class MyOuter {
private int x = 7;
public void makeInner() {
MyInner in = new MyInner();
in.seeOuter();
}
class MyInner {
public void seeOuter() {
System.out.println("Outer x is " + x);
System.out.println("Inner class ref is " + this);
System.out.println("Outer class ref is " + MyOuter.this);
}
}
public static void main (String[] args) {
MyOuter.MyInner inner = new MyOuter().new MyInner();
inner.seeOuter();
}
}
the output is
Outer x is 7
Inner class ref is MyOuter$MyInner@113708
Outer class ref is MyOuter@33f1d7
Inner Classes 9
So the rules for an inner class referencing itself or the outer instance are as follows:
■ To reference the inner class instance itself, from within the inner class code, use this.
■ To reference the �outer this� (the outer class instance) from within the inner class code, use <NameOfOuterClass>.this (example, MyOuter.this).

So, M.Aquino -
Outer class's instance variable can be referenced either directly( Remember nonstatic inner classes have unlimited access to outer class's instance variables.) or through outer class's reference like this . <NameOfTheOuterClass>.this.nameOfTheInstanceVariable.

Hope this helps ...
rgrds,
Jane
Hi all,
I wanna pass SCJP with 100% score.Its a business requirement.Is it really possible to score 100% in SCJP 1.4 exam.My exam is scheduled on May 2nd. Help Me!
Thanks & Regards
Jane
Hi,
Thank you Barry for letting me know about this spurious wakeup.Got the point now.Will u please give me an example of a condition to be checked in this loop construct.

"while (<condition does not hold> ; )"

Thanks & Regards
Jane
Yes,Amit .. got the point
Thanks
Jane
Oui sowmya!
exactement.I agree with u.
jane
"Which object is not eligible for garbage collection after method m1 returns?".

Carefully observe this question ... it is " after method m1() returns " not "after main method completes ".
At this point of time object created by "new J()" still exists which is having references to the island of objects.
So, obviously none of the objects is eligible for garbage collection.

Regards
Jana
Hi Srivatsava,
Here I am presenting 3 runs which are executed on HP-UX unix machines..with slight code changes

This is without any code changes .. ie without any notify methods
hpmdd137::/kbase/java/practice >>
java SyncNotifyAll
Waiting for calculation...
I am calculator thread
I am notified Thread[Thread-3,5,main]
Total is : 4950
Waiting for calculation...
Waiting for calculation...
hpmdd137::/kbase/java/practice >>
(Notice the output and particularly last two lines)

This with a join() method in Calculator's run method
hpmdd137::/kbase/java/practice >>
java SyncNotifyAll
Waiting for calculation...
Waiting for calculation...
Waiting for calculation...
I am calculator thread
hpmdd137::/kbase/java/practice >>

This is without join() and with a statement at the end of Calculator's run method .. just before the thread is going to die ( ie it finishes the execution of run method)
hpmdd137::/kbase/java/practice >>
java SyncNotifyAll
Waiting for calculation...
Waiting for calculation...
I am calculator thread
I am going to die
I am notified Thread[Thread-3,5,main]
Total is : 4950
Waiting for calculation...
I am notified Thread[Thread-2,5,main]
Total is : 4950
(Notice here the last thread is waiting).

U said ... "the execution of Calculator thread gets completed before the last thread(SyncNotifyAll) runs. So the last thread goes into waiting and no one is there to notify".What if the Calculator thread is waiting for SyncNotifyAll threads to get completed using a call to join.In that case please refer the 2nd run .. all the 3 SyncNotifyAll threads remained waiting ... ( What do U say?)

Totally .. I don't understand why these threads are coming out of wait state in few runs and not at other times .....

I noticed it on both windows and HP-UX m/cs...(I thought ..as Threads in java are implementation dependent at least to a little extent .. I could find any diff in the way threads are notified).

But .. I couldn't deduce anything now..
why this is happening ...ouf!
Regards
Jane
Bonjour! M.Wong,
I tried the same without any notify or notifyAll calls ... For the first time, I got this output...

D:\>java SyncNotifyAll
Waiting for calculation...
Waiting for calculation...
I am notified Thread[Thread-2,5,main]
Total is : 4950
I am notified Thread[Thread-1,5,main]
Total is : 4950
Waiting for calculation...

and the system stood waiting .. I had to press ctrl+c to come out ..

and in later executions I didn't get this kind of behaviour .. all threads are nicely getting finished . If one of the clean up procedures of JVM are giving notification on the thread object .... how come this kind of behaviour is possible ...

and also ... objects would never become eligible for garbage collection as long as there are refs from any live thread ... then .. what abt this clean up procedure ... I am not getting the point .. will U please make it little clear .
Thanks & Regards
Jane.