posted 16 years ago
>>1.ob2.equlas() means deep comparision.but here ob2 is obj2 object and having no value.and oba is obj1 objeact and having values (1,2).how come the result true is displaying.
..is because, you are initializing it to 1 and 2 in the class declaration of obj2. Try changing the defaults to different values in obj2 and see what happens.
>>2.How come the lin3 is not showing any classcastException
Why? In the class obj2, as per your code, at line 3, it is expecting an object of type obj1 and in the main() you are passing obj1, therefore no exception.
At line 2, try passing ob2 instead
and you will see the exception.