Sarikaa Bhatnagar

Greenhorn
+ Follow
since May 10, 2005
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 Sarikaa Bhatnagar

Hi,

I am facing similar problem. Also do you know how to download the logo and is the certification gonna expire in 2 years ?

Thanks,
Sarika.
Hello All,

I cleared the exam with 90% today. Want to thank - all the members of java ranch for their prompt help, all the time!!!


Thanks,
Sarika.
16 years ago
HI,

this is exactly what i understand and this is what is causing confusion.
When a copy of array is passed to f() then i believe there are totol 5 objects. 1 array reference itself and 4 its internal objects. Now when 3 objecs and the array ref itself is set to null - that makes the count 4 for objects eligible for collection.

I understand that the main() array is still there and still pointing to the original array.

Please explain!
Hi,

Can anyone pls help. How many objects are eligible for GC when System.gc() is invoked() in the following code:


class MyClass{
public void finalize()
{System.out.println("finalize");}

class Test{
private static void f (MyClass[] array){
array[0]=null; //line 1
array[1]=array[0]; //line 2
array[2]=array[1]; //line 3
array=null; /line 4
}

public static void main(String agrs[]){
MyClass[] array = new MyClass[4];
for (int i=0; i<array.length;i++)
array[i]=new MyClass();
f(array);
System.gc();
}

}//end class




correct answer is 3 whereas i feel it should be 4( the objects at line 1,2,3 and 4). In the method f() 3 out of 4 elements are made null and the array refernce itself is made null (at line4) then how come only 3 objects are eligible for GC.

thanks,
Sarika.
Hi,

Can anyone please help me with the conversion of decimal -20 (negative 20) to octal and hexadecimal and vice versa.

Thanks,
Sarika.
Hello friends,

I am planning to take the exam this monday. Want to confirm few things abt the real test environment ( as i am using wizlabs for preparation)

1) Is there "previous" and "next" option
2) Is there any option to mark the question and come back to it later on
3) Is it possible to review all your questions in case you finished your exam before 2 hrs.
4) I have read on prometric site that "exam tutorial and client survey" is part of the test. What actually is this and how much time does it take.


I appreciate if anyone can help me with this and in case you want to share any inforamtion,which you feel is importnat abt the test environment - pls help me by doing that.

Thanks again.
Sarika.
thanks a lot! the explanation is convincing :-)
thanks, this is correct but wht i dont undersand is that why cant we access it with parent object because its a variable of parent only and child class has simply inherited it ?

Sarika.
Hi,

pls look at this;

Interface inter{}

class base{}

class derivedone extends base implements inter{}

class derivedtwo extends base{}

class test
{
public static void main(Stirng args[])
{
base b = new base();
derivedone d1 = new derivedone();
derivedtwo d2 = new derivedtwo();
inter i ;

//case 1
d2 = (derivedtwo)d1;

//case 2
i = d1;
d2 = (derivedtwo)i;


}
}

case 1 gives the compile time error whereas case 2 gives runtime error. Can someone explain me the theory behind this because if we evaluate teh case 2 expression d2 = (derived2)i then it becomes same as case 1 as shown below

1) d2 = (derived2)i
2) i refers to d1
3) d1 = new serivedone()

so eventaully this expression is same as case 1 d2 = (derived2)d1 then why case 1 gives compile time error whereas case 2 gives runtime error.

thanks,
Sarika.
HI,

my ques is why ++ and -- are not evaluated first when as per operator precedence rule ++ adn -- takes precedence over / operator. So why the division happend 8/3 and not 9/2

thanks,
sarika.
Hi,

PLs help with this,

class MyClass
{

static private int mycount = 0;
int yournumber;

private static synchronized int nextCount()
{
return ++mycount;
}

public void getYourNumber()
{
yournumber = nextCount();
}

}

The correct answer is "each thread will get a unique number". Can someone explain why ? I think that as the "getYourNumber()" is not synchronized so many thread can access it at the same time and can get the same number. I am assuming that as "nextCount" is private so no thread is accessing it directly to get the unique count.

thanks,
Sarika.
Hi,

Can anyone pls tell why cant we access variable x when it is protected and pacakge is imported ?

Parent.java
-----------

package par;
public class parent
{ protected int x = 9; }

Child.java
----------
package other;
import par.*;

class child extends parent
{
public static void main(String args[])
{
parent p = new parent();
system.out.print(p.x);
}
}


Thanks,
Sarika.
Hi,

am sorry i think the sentence(Imagine a case when a thread has called setx() and sety() and setxy() are not called by any thread ) above is not very clear so reframing it.

Imagine a case when a thread has called setx() only and no other methods are called by any other thread(sety() and setxy() are not called by any thread ).

Thanks.