This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I came to kwow that only stuff marked static and public is eligible to be used using static import.
Friends please let me know on which page K&B mentioned that public is must. Actually i have finished reading K&B and plannning to take SCJP 5.0 in a day or two but when i am taking the mock exams , i am finding such questions whose theory is not present in K&B (like the above question). This is really bothering me.
Can you guys help me out and moreover please give me some tips about the exam. Thanks in advance
I don't think public is a must. You need public in your example because the imports you're doing are from a class which is in another package. Therefore it is normal than to be visible, they have to be public. Nothing to do with the import static statement.
take a closer look.. if you want to access the variable J from the 2nd class then you should declare it PUBLIC OR PROTECTED... because the 2nd class is in a different package and if you want access to J then declare it public and access it or else declare it protected and make the 2nd class a sub class of the first.. then also it will work...
default access and private wont suit here due to the reasons given above...