Originally posted by nikhil nandu:
static final int MY_FLAG = 16;
Method removeFlag takes int x and returns int value which do not
contains flag MY_FLAG. Which of the following implementations are
correct:
A. return (x & ~MY_FLAG);
B. return ~(x | MY_FLAG);
C. return (x & MY_FLAG > 0 ? x-MY_FLAG : x);
D. return ~(~x | MY_FLAG);
This is very confusing stuff.I didn't have ans for this qns.Please help.
Thanks in advance.
Originally posted by sunilkumar ssuparasmul:
i wanted to know in what order does a class initialize meaning if u have a'
1)set of class level variables
2) static block initializer
3)instancs block initializer
static blocks and static variables, if any ,would get initialised first. These are initialised when the class gets loaded. as these are per class variables
The next comes initalisation of other class variables and instance blocks. And these occur when ever an object of the class
created and these get initialised in the order they are declared in the Class definition.
HTH
Sasi
which would initialize first?
thanks in advance
sunil.s
Originally posted by amit sanghai:
To Sasi,
I didnot understand your answer to the first question!!![/B]
Originally posted by amit sanghai:
Hi sasi,
Q1) Why does the println() function does not work inside finalize method() ?
There seems to be some twist here. See the API doc
"protected void finalize()
throws Throwable
Called by the garbage collector on an object when garbage collection determines that there are
no more references to the object. A subclass overrides the finalize method to dispose of
system resources or to perform other cleanup. "
What above means is that finalize is called when the object has already gone out of scope( and at this point of time it is at the mercy of the gc to be started by OS) that is why println method is not working. if we call explicitly the finalize method it is working. No more references means it is out of scope of all methods .
Q2) I meant object is out of scope? I think that you cannot find out whether an object is available for garbage collection. Is that true?
Originally posted by amit sanghai:
Q1) What are the thread-to-thread communication?
Q2)what is a deadlock? How can you avoid a deadlock?