shreya prabhu

Ranch Hand
+ Follow
since Feb 10, 2007
Merit badge: grant badges
For More
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 shreya prabhu

try
{
int x=0;
int y=9/x;

}
catch(ArithmeticException ex)//line1
{
System.out.println(ex.toString());
System.out.println("arithmetic exception");
}
System.out.println("finished");

i thought the ouput would be arithmetic exception finished
but at line 1 i am getting a error cannot convert from arithmeticexception to throwable.can anyone please clear my doubt
i am confused regarding order of execution?
is it:
static initializers and static variables first and then instance initializers and instance variables?please clear my doubt or is it in the order of declaration?
this question is from kathy sierra gabage collection questions at the end of the chapter..
can anyone please tell me which are the methods that can stop a thread from executing?
wait()
does yield stop it from executing?are there any other methods?
thanks in advance
12. void doStuff3() {
13. X x = new X();
14. X y = doStuff(x);
15. y = null;
16. x = null;
17. }
18. X doStuff(X mx) {
19. return doStuff2(mx);
20. }//here answer is not sure when object created at line 13 is garbage collected but outside the method we have made the references null so why is it not garbage collected?
i am sorry i mean in the first case methods are static.
parent{}
child1 extends parent{}
child2 extends child1()

there is same method in both parent and child1 with same name and signature and method is not static.then can i call the method in parent
by using this :
((parent)this.)methodname();

if the method is not static then it is not possible to access the method in parent from child2.am i right?please clear my doubt.
0xfffffff1
how do i find the decimal value of this?
1111 1111 1111 1111 1111 1111 1111 0001
but after this what needs to be done?
actually above 2 are examples from whizlabs mock exams.why assertion in the first program valid and not in the second one?i thought it is invalid to use assertions to check arguments in public method.but not able to find out why then is the second condition valid?
public class AssertTest{
public void writeFile(FileOutputStrem fout){
assert fout!=null:"Invalid Handle file";
try{
fout.write(1);
fout.close();
}catch(IOException ignore){

}
}//invalid use of aasertions should not be used to check validity of public arguments


public assertDemo{
public String getLanguage(String code){
String str=null;
assert str!=null;
return str;
}
} //irrespective of visibility it is valid to use assertions tocheck for postconditions

not able to understand what exactly is the difference.please help to clear my doubt.
int x=-5;
assert(x+1)>0;//line 1
assert x-->0;//line 2
line 2 is said to be invalid as it changes the value of x but line 1 is valid ?why?
in this case how is the out put -1?
-1>>1
first:0001+1=0010
complement:1101
right shift:1110

1110
-1
will result in what value?please clarify my doubt.
thanks
i am preparing for scjp 1.4 so it includes shift operators
i am not able to understand this:
byte b=-42;
int result=b>>4=-3

how will i get -3?

i thought ~2=-(00000010+1)=-3