Shardul Kumar

Greenhorn
+ Follow
since May 24, 2009
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 Shardul Kumar



Whats exactly happens here? Why am I getting an error while printing the value of x in the static block?
13 years ago
Yeah Thnx!!
It helped a lot
Thank you guys
13 years ago
What does it exactly mean to have a package statement in the beginning of a java code.
Does it mean :
1> The class file generated after compiling the java file should be in a directory having same name as in the package statement?

PS : Am I missing some more concepts?

Please Help!!!
13 years ago



how line 2 is working and rest of the line followed by it..

actually this problem is about which lines give an exception..
please let me clear it that when we do casting is it reference variable casting i mean does object type created play any role???

Ankit Garg wrote:please Use Code Tags when you post a source code. You can edit your message using button and then add code tags to it.


Line 15 is just a normal downcast. m is downcasted to C and automatically upcasted to B (Since class B implements Min and C extends B, thus C IS-A Min). Line 17 is tricky. But suppose the reference m points to an object of type B, then the object pointed by m will be assignable to a reference of type A (as B IS-A A). That's why the cast is allowed. So the fact is, a cast between an interface and a non-final class is always allowed. That's because there might be a class that implements that interface and extends that class. Again line 18 is just a normal downcast. Line 19 downcasts b2 to type C and then it is automatically upcasted to Min. Line 20 is also a normal downcast...




but m is null


can anyone xplain this casting problem from line 15 to 20.....
thanks.
I'm preparing for SCJP....while solving problems with the WhizLabs Exam Simulator.
Having problems with Reference Variable Casting!!!
Please provide some links so that I can clear the doubts....
Thanks!!!
Thankyou guys.
I've got the concept correctly.
Thanks again.
14 years ago
here is the code: it gives compilation errors. why?

14 years ago
Thanks Henry for the help.
I've got them now.
14 years ago
I just want to have a clear picture of the terms like reference.
I get confused when terms like member variables, instance variables etc come.
Please help!!!
14 years ago