Jugal Hans

Greenhorn
+ Follow
since Aug 30, 2004
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 Jugal Hans

This was my interpretation of the code.
When y was created "i" gets the value 20, no problem
Then when z is created it passes the copy of the memory reference stored in y to the constructor, "a" is pointing to the same object as y.
then this() calls the no arg constructor which makes the value of i to 20 and then value of i is again changed to 30 (code i = 30).
All this time a,y and z are pointing to the same memory location.
so when GetVar() method is called it will display 30.
Can u tell me where did i go wrong ??

Thank you
[ December 22, 2004: Message edited by: Jugal Hans ]


In the above code I was expecting 30 to be displayed on both the occasions.
But it displayed 20 and 30
How come ??
Can anyone please please explain what is happening here ???

Thanks in advance for the help !!


Passed SCJP 1.4 with 88% marks.
It was a good experience working in AS/400 and learning Java in rest of the time!!


First of all "heartiest congratulations" on your score.
I am also from AS/400 background and just like you, I am also aiming to get java certification.
Can u give me some tips on how to approach the exam bearing in mind that I am also from AS/400 (or RPG to be precise) with "0" knowledge of OO concept.
Though by now I am pretty much OK with the concepts but if you can throw a little more light on how to prepare for the test , that will be really great!!

Thank you in advance.
19 years ago

so when you try to print such an object the class' toString() method would be called.


why would the method be implicitly called ?

You can only override methods, not instance variables(t.a)


If that is the case then when t was created with constructor of the subclass it actually called the base class cosntructor ? is that correct interpretation ?

Thanks
Hi All,
If a for loop ends with a semicolon it iters itself till the conditions returns false,why was this need ever to do that ? I am really curious to know why is this treated correct ? and in what scenarios does it benefit the programmer ?
I mean, semicolon in the end doesnt seem to be in line with other statements in terms of syntax ?
and with just the use of a small semicolon u r disfiguring your code too much, i think.
But anyways regardless of my thoughts I guess we have to bow down in front of the compiler ??

Thanks
Hi all,
If a negative number is represented in 2's complement form then what is the use of sign bit ?
I know the question sounds silly but can anyone throw light on this topic !!

Thanks
Thank you all.....
Feels good
Thanks for ur replies..
ok, so according to Corey McGlone, there is no way to find out the changed value immed after the compiler actually changes it, right ?

Then is it safe to assume that pre and post increment operator doesnt really matter in FOR loop ? This is what Saheed Adepoju the prevoius poster also thinks !!

Thanks
A simple question for java gurus:
I would like to request some detailed explainaition on ++ and -- operator.

I know in the above case it will display 0

but it confuses me when used in for loop

1. In the above statement at what point, i will be incremented ?
2. If I want to see the value immediately after the change, then at what point should I execute the println method ?

Now if i++ in for loop is changed to ++i the output still remains the same.
So exactly at what point I can see the changed value ?

Thank You!
I guess I am back to "square 1"

OK,so does that mean at some point the array a was referencing two array values at the same time ???
1. when a=b[3] is evaluated
2. when the left most array a evaluated.

Thanks for the explaination.
So you also agree to the fact that it should display 2,
but on compiling and running the above code it displays 1
why ???
[ December 01, 2004: Message edited by: Jugal Hans ]
Hi,

Orginal code pasted below:


It is still hard to evaluate
I know finaly value in a[0] is displayed bcoz i ran the code to see.
But I dont understand how did that happen ??
This is what i thought:
After a = b array a will also display the same values as array b
which means
a[0] = 2
a[1] = 3
a[2] = 1
a[3] = 0
so a [ (a = b)[3] ] will evaluate to a[0] which is 2, but why does it display the old array element ???
Please help me understand this !!!

Thanks
Ok,
I understand that arrays need to be initialized explicitly
So assuming the array is initialized with proper values and as per ur answer Arr[2][] contains only arrays again then why does Arr[2][] show junk values? What is it that it is showing?


You can only check data when you fully dereference the array


What do you mean by the above statement ? I did not get a bit of it...
and I think my answer is hidden in the quote above.
[ November 17, 2004: Message edited by: Jugal Hans ]
19 years ago
Thanks for the reply.
That is how I also visualize conceptually.
So for eg:
If the array is defined as Arr[2][3],
then if arr[2][] is interrogated then it should show data containing
in arr[2][1] and arr[2][2] and arr[2][3]...., but it does not ? Can u tell me more in detail how does the data reside ?

19 years ago