This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "null" Watch "null" New topic
Author

null

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521


why does this not give any compile error? the questions was from whizlabs....i created my own code to test the concept


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Raju, UseAMeaningfulSubjectLine for your topics. Just writing "null" or similar doesn't tell much about the topic. You've been reminded about this many times.

Try this simpler code

Basically, when you call a static method or access a static field on an instance of the class, the compiler replaces the instance with the type of the instance. So your code would actually look to the JVM like this


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Rajiv Chopra
Ranch Hand

Joined: Dec 19, 2008
Posts: 62
Ankit Garg wrote: when you call a static method or access a static field on an instance of the class, the compiler replaces the instance with the type of the instance.


Thanks Ankit..


Rajeev Kumar
SCJP 6.0 Certified 96%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: null
 
Similar Threads
final arguments
overloading doubt
final instance variable
can "null" be considered as an object?
NullPointerException