swarna kumar

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

Recent posts by swarna kumar

i came across this ques in RHE book,
code:
String s="abcde";
StringBuffer s1=new StringBuffer("abcde");
if(s.equals(s1))
s1=null;
if(s1.equals(s))
s=null;
the compilation succeds,
actually, we can't compare String to a StringBuffer. If we do, it would return false,
then how the compilation succeds without giving any exception.
let me know this
swarna
hi sean,
we can not force the GC, but if we can set the obj.ref variable to null, hinting the GC to garbage collect the objects referred by the variables.
so from this programm,how can we say the ans is 4,
could u pls correct me,
swarna
thanks corey ,
now i get the result

regds
swarna
hi corey,
k= 1+(-4)-5-2= -10. or
k=1+(-4)-6-2
which is correct how?,
regds
swarrna
malik is right,
for statement systax is wrong;
for(initialization;condition;iteration){
}
this is the syntax,here thers is no iteration part.
regds
swarna
hi,
i got little bit confusion ,
once we solve the expression we get k=-10,
then
System.out.println("The value of k is " + ++k);
again here is one expression ++k right, if we solve this we get -9,
how we get -10,
correct me this,pls
regds
swarna
Which is the earliest line in the following code after the object created on the line marked(0) will be a candidate for being garbage collected, assuming no compiler optimizaton are done?
public class Ques{
static String f(){
String a="hello";
String b="bye";//(0)
String c="b+"!";//(1)
String d=b;
b=a;(2)
d=a;(3)
return c;//(4)
}
public static void main(String args[]){
String msg=f();
System.out.println(msg);//(5)
}
}

chioce is:
after line 1
after line 2
after line 3
after line 4
after line 5

Actually String literals are not garbage collected then, how could we choose ans,
swarna
thx valentin and jess,
thx for good explanation,
swarna
thx anthony,now i got it.
swarna
hi guys,
examine th code,
class demo{
public static void main(String args[]){
int i=012;
System.out.println(i);
}
}
the result gives 10, why so? and how?,give the full details.
thx
swarna
[LIST]
hi neha,
the ans is 48,
bcoz, j=3*4*4;(here i is 4),right
j=48.

swarna
Thanks guys for your quick response,
bye
swarna
hi,

this is very basic ques,but i couldn't get,

what are the legal identifiers i java?
i)Integer
ii)�test
iii)-123
thx
swarna
hai friends,
What is the result of executing the following fragment of code:
boolean flag = false;
if (flag = true) {
System.out.println("true");
} else {
System.out.println("false");
}
}

true is printed to standard out
false is printed to standard out
An exception is raised
Nothing happens

my answer is b,
but the answer is a,
anyone can correct me,
thx
swarna
hai fisher,
the answer is b.
b'cas, uncoordination of threads will result in the data be corrupted.

the option c is not correct,b'cas a thread which is suspended, cannot be restarted.
swarna