Baiju Scariah

Ranch Hand
+ Follow
since Mar 17, 2005
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 Baiju Scariah

Book books[] = new Book; --> Is just an array reference, you haven't created object yet.

Thus before assigning any value you must say

for(int i....)
{
books[i] = new Book();

}


12 years ago
Just print the value of k and check

int k=System.in.read();
System.out.println("Value of "+k);

Returns next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255.
12 years ago
As the error says, your system (or memory allocated to jvm) is running out of memory.

You may allocate more memory using when you run java program "-Xms512m -Xmx1024m", if there are more memory in your system

Please note that, you may change minimum and maximum memory to 1024 and 2048, if there is more than 2 GB memory
StringBuffer c=new StringBuffer("def");

and

"StringBuffer c" in "static void operate(StringBuffer b, StringBuffer c) " are not same.

When you call "c=b;", value of b is assigned to the temporary varibale, not to the c created in main().

So, if you print c in operate, result will be "abcdef", in main as it is not modified (only its copy is modified) it would print "def"..

Good to spend some time understanding differences between String & StringBuffer and concepts of pass by value & pass by reference..



12 years ago
In Java String is immutable - meaning not modifiable. You may modify the String reference and store a new string there.

Ex:
Modify StringReplace() as give below..

public static String StringReplace(String t)
{
t=t.replace("j","i"); //It should have replaced "j" from "java" with an "i"
return t;
}

and

in main() as given below

s = StringReplace(s); //what happens over here?

This would give you desired result.
12 years ago
Thanks.

Somehow, my search wasn't successful...

Baiju
13 years ago
Thanks to all for the update.

But, I am interested in knowing is there a default value for -Xmx. In other words, if we don't specify anything at runtime, does java has any default value?

Thanks
Baiju S
13 years ago
Hello,

Can someone please let me know what is the default minimum and maximum heap size for JVM, if -Xms and –Xmx are not specified in Windows and Solaris environment?

I am using jre1.6 on Windows VISTA, XP environments

I am using jre1.6 on Solaris 10

Thanks,
Baiju S
13 years ago
Yes, Number of right answers will be given with the question if there are more than one.

That will be the only diffrence SCJP real exam and Mock exams

Baiju Scariah
SCJP - 93%
That is correct.

My point was on assigning the array reference to an Object refernce - show him that if that he was unnoticed. Casting must be done only when it is really required right??... Otherwise anything can be stored in anything and casted later into the real type (Most of the cases).

I really agree with you that as an answer for this Qn.
It has nothing to do with java compiler. Whether it is object reference or an array reference complier is not bothered about that. (Hope you know that an array refernce can be stored in an Object instance
ex: Object obj1 = new String[10] )

In java no error at the time of compilation doesn't mean that what you have written is correct.

There is my answer!!!

" Java compiler will not complain for all the mistakes you make.... "
Qn is not clear??....

If you call wait method an object - it will release the lock and wait. As soon as the waiting period is completed it will put in the waiting pool for the thread scheduler attention.

Once scheduler assign the CPU that object will continue its excecution.

if the Qn is about the different value printed JAVA - never assure the exact behaviour of thread execution since it depends on other factors also.

Am I answer to your Qn??
Object[] p=new Object[2];
Object[] q=new Object[2];

String s="hi";
q[0]=s;
s="hello";
q[1]=s;

p[0]=q; // Wrong

Write like this:
p[0] = q[0];

Both are single dimension arrays. An element of a single dimension array can't be a reference of another array.

Hope it is clear??

Baiju Scariah
SCJP
I couldn't get your question. Could you please exaplin that frameset?..

Since this call is aprt of a very big application I don't have any control over the applet frameset.

I am getting the AppletContext and calling the showDocument() function with url and "NewFrame" string
17 years ago
" The name argument you are passing does not match an existing frame, so it creates a new top-level window. "

But I am giving the same name every time
17 years ago