Slightly Uber

Greenhorn
+ Follow
since Mar 21, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Slightly Uber

Every time you create a NEW string it is a new OBJECT - thus it cannot be == . You are dealing with 2 seperate OBJECTS and == checks to see if the operand on the left is the same OBJECT as the operand on the right. the String .equals() checks to see if the operand on the left holds the same VALUE as the operand on the right.
I hope this clears it up a little for you =). Not trying to yell, just stressing the important parts
I too was disappointed in my taking of the exam. I actually failed with a 59%. I thought the exam would cover more areas than it died. I think the questions are random, but i had several I/O questions right off the bat. Also many threading questions, which like another poster said I didn't take seriously enough. I tried to grasp as much as I could off every topic listed in the objectives. I'm taking it again on friday and have been concentrating on I/O and threads everyday. Beign a GUI person i don't use threads and I/O that often and I only had one GUI question - at least i got that right =)
Oh and by the way, when an object is set to null it is ready for garbage collection. LOL
24 years ago
If I am not mistaken, and please corrrect me if I am wrong, an instance of a non-static inner class can only exist with an instance of an outer associated with it.
So my guess would be to add this at your //:
Outer.Inner inner = new Outer().Inner()
then you can access the inner variable x by:
System.out.println( inner.x );
Inner should also be able to access all the variable in the Outer class as well.
I think I'm right - not certain though
Hmmmm, not sure on this one. I'm studying from the "A Programmer's Guide to Java Cert" by Khalid Mughal and it states:
"...a top level static nested class can define both static and instance members like any other package level class. However, its code can only directly access static members in its enclosing context."
I also was a little off on this question, and prolly still am. Best i can come up with is that any object that enters synchronized code can have a lock. That object itself doesn't have to have synchronized code in its source file - can be any regular object. It's the method that the object is passed to that should be synchronized to obtain the lock of the object. So i am guessing that all objects have monitor(lock or semaphore which ever you prefer). Please correct me if I am wrong.
And the second question I think would be that a private class would have no accessibility - thus the JVM would not be able to access it to compile or run it and no other class would be able to reference or subclass it, thus rendering it pretty useless. Also please correct me.
oops, sorry:
My guess is that the first object's v.i was changed to 20 in another, but the second object's v.i was changed after creation leaving the first object's v.i unchanged
is completely wrong:
the second object's v.i is not changed at all. so the first object's v.i is changed to 20, and the second object's v.i is 10.
Boy, I am really confused =)
ok, I ran and compiled this program so I am certain the answer is:
10 0
20
The confusion lies in the statement:
ValHold vh = new ValHold();
v = vh;
Two ValHold objects have been created( hence the v.i = 10 part ), but I don't have a definate answer as to why the v.i in amethod() has the value of 20 when another() completes.
My guess is that the first object's v.i was changed to 20 in another, but the second object's v.i was changed after creation leaving the first object's v.i unchanged. However, the cariable v seems to reference 2 obects( I think ) and I don't even know if this is possible. Somewhere the 2 objects have different values, but the same reference. I really want to know the answer to this, so please, please anyone correct me / us.
Thank you for listening to my confusion.