Gokul Somasundaram

Greenhorn
+ Follow
since Jul 17, 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 Gokul Somasundaram

Thanks everyone in the Java ranch. Actually i have never coded in java. I have some small experience with C++ some 5 yrs ago.
In my company they were compelling me to take the certification. But i wanted not to spend much time in reading books and to clear the certification fastly. The work is also hectic in my case. So the only source of my knowledge is Java ranch and its redirections, where contents are available free.
Once again thanks everybody for their passive contribution in my success.

Thanks,
Gokul.
18 years ago
The API says like this
Hash table based implementation of the Map interface. This implementation provides all of the optional map operations, and permits null values and the null key.
So one null key is allowed. One more important point to note is that HashTable doesn't allow null values and the null key.

Thanks,
Gokul.
Hi Kevin,
Just to come back to your question,
1) Constructors are a way to instantiate the class. If it is a public constructor, then everybody can instantiate a class. If it is a protected constructor, then only the subclasses can instantiate the class. If it is a private constructor, then only that class can create an instance of it. Even without making use of the constructor, you can access the static methods of the class.
2) Inner classes can be private, because the inner classes are like any other methods and variables inside the top-level class.
I may advise you to just to go through some of the basics of object oriented programming(if you don't mind).

Thanks,
Gokul.
Hi Ravi,
When you pass objects as parameters to methods, java doesn't pass their references, but it passes another reference which still points to the same object. So if you have the object 'a' pointing to 100, then a is the reference and 100 is the object. Assume that 100 is stored in a memory location 0x1234. a is a reference to that memory location. Now when you send it as a parameter, then java creates one more reference which still points to the same memory location. So effectively you are having one object with two references.
If you are clear till that point, whatever change you make to the object inside the method will get reflected in the calling method. But whatever change you make to the reference just stays there. It doesn't come back to the calling method. if you call a.append(), it operates on the object. But in the second statement, you are redirecting the duplicate reference. So it is not affecting the object which is stored in the place where the reference was pointing to previously. So b has the same value.

Hope i am clear.

Thanks,
Gokul.
Hi Kevin,
I am going to take the exam in 2 days without much preparation. When you just narrate about yourself before the exam, it just resembles me. But i am taking 1.4. Let me try to answer your questions.

1) There is nothing like a protected outer class. Classes can have either default or public access. If the outer class is default and if you declare a public inner class, then that inner class will be considered like any other public member and can be accessed with the outer class object for classes in the same package.

2) constructor should ideally be public (except for singleton classes).So having it in default class again makes that class instantiable by every other class in the package.

Please correct me, if i am wrong.

Thanks,
Gokul.
Kumar,
I think, i may be a bit unclear. Actually i meant the same thing, which you have said. I am saying that piece of code won't work and throw an error.

Manoj,
Yep, we are on the same boat.

Thanks,
Gokul.
Then tell me why is this not working?
public class Test{
public static void main(String args[]){
String [][] argCopy = new String[2][2];
int x;
x = args.length;
for(int y=0;y<x;y++)
{
argCopy[0][y] = args[y];
System.out.println(" " + argCopy[0][y]);
}
}
}

The above two programs worked because the reference has been repointed. If you try to access the object instead of the reference, then you will get the error.

Please correct me, if i am wrong.

Thanks,
Gokul.
But how is this question related to GC(Question Title)?
JVM 1.3.1 is a 32 Bit JVM. So you can address upto 2^32 bytes (4 GB). There are Memory requirements for JVM other than Heap like the Memory requirement for the Threads etc.
To my knowledge, you can have a heap of 4GB - Thread stack size * (no. of threads). 3.5 GB Safely.

With JVM 1.4.2 you have the -d64 option with which you get a 64 bit JVM and you can address more space 2^64 Bytes(Very huge).

But as you take larger heaps the no. of GCs reduce(advantage), and the time taken per GC increase(disadvantage). With JVM 1.3.1, the GC is single threaded and it will stop the application threads. So Check the response time affordability of your application
18 years ago
Sorry the above message is a Type O.

What i intended to explain was after returning from the statis method, at the line 1, we have

x=x2;

So the object which x was initially referring to has no reference now and it is ready to be GCed.

Anything wrong in my statement?
Let us go line by line:

public static void main(String args[]){
X x=new X();//Object creation under reference x.
X x2=m1(x);//A copy of Reference x is passed to the method.

static X m1(X x1){
x1=new X();
return x1;
}


X x3=new X();

x=x2; //Line 1

docomplexStuff();
}
Please post the question and all the choices.
I disagree - if your application has just created a display that you know the user will take some time to read, it is an ideal time to call System.gc() with minimum impact on the perceived program speed.

There may be some other user who has hit the server and waiting for the response. I think calling system.gc() may affect his response time.
18 years ago
I hope it all depends on the size of each record in the result set.
i would advise
1) Find out the size of the 10,000 record result set, you want to display. Set the result set to null and run a system.gc(). Take a memory usage stat before and after gc.
2) If it is too huge, then you have to resort to paging.
3) But even if you display 5 records per page, get the optimum no. of records from database at each fetch. This will reduce the no. of calls made to the database.
18 years ago
The Program returns 5 for me in Java 1.4.2