Win a copy of Rust Web Development this week in the Other Languages forum!

Gautam Pandey

Greenhorn
+ Follow
since Sep 21, 2007
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 Gautam Pandey

final members instance variables can be left blank during declaration , but it has to be initialized before the constructor of the class completes. So in your case the first constructor takes care of the variable q and initializes to 1. if you comment out the line in the constructor, it won't compile.

Thanks , Hope this helps
since equals method is not overidden in MyClass , it uses the Object's equals version which returns true on if the objects are referring to the same object. Since in your case its creating two different objects , it returns false.
Hi ,

equals method for Wrapper classes returns true if both the value inside the wrapper classes are equal and they are of the same type(Double,Float..etc).
But in K&B book neither the class diagram show that relationship nor it is mentioned in any part of the book.

Guys Pl. clarify this issue.

Thanks


Out put i got is
before in static block k= 1
after in static block k= 2
before in NON static block k= 2
after in NON static block k= 4
Created t1..
before in NON static block k= 4
after in NON static block k= 8
Created t2..
8
8
8

it looks like the static block is executed only once so k =2
then the first instance creation will execute the non-static block making k = 2*2 = 4
then the second instance creation will execute the non-static block again making k = 4*2 = 8
so i1.k,i2.k and k (shadows the k variable in the interface,to print the value in the interface i think I.k should do it) will be 8
Got it !
The (a=b) is evaluated first then the index [3] is applied to the new reference array (now a is pointing to b) so now it's a[3] which is actually b[3]


I agree with the above explanation , but when i first look at the code , i took it this way
(a = b)[3] ==> a[3]=b[3] ==> a[3]=0 ==> 0
so a [ (a = b)[3] ] ==> a[0]


would have been also the right answer if it were

Were you able to compile and run this ?

My compile error was "The method m(GFC211 x, GFC211 y) is ambiguous for the type GFC213"

Are you sure you were able to compile and run ?
From one of Dan's Mock exams



Pl Help me understand this..
Why does this give me compile error?
Isn't the last method m(GFC211 x, GFC213 y) the most specific one the compiler can choose?
I know that if this line (#2) is commented out, the most specific one is m(GFC212 x, GFC212 y) (line #1) and it compiles.

Thanks
Nice Code

Output is

main started
Y-a finalizing
main ready
The object which a refers to after the lines (meaning now a is pointing to b's object and both b and c are pointing to c's object) is not referenced by any variable or reference. c's not changed.
so i think only ONE object (originally referred to by a)is eligible. I don't see any ambiguity here.
[ September 24, 2007: Message edited by: Gautam Pandey ]
The explanation given in the answers is

The Object referenced by obj is of type Sub[], and the reference, base, is of type Base[]. The assignment expression, base = obj requires an explicit cast to type Base[] as follows: base = (Base[])obj.