hai friend, The question given below is from a mock test, the ans is given as d but i feel even that is wrong plz clarify. Which of the following are correct. Select the one correct answer. 1. An import statement, if defined, must always be the first non-comment statement of the file. 2. private members are accessible to all classes in the same package. 3. An abstract class can be declared as final. 4. Local variables cannot be declared as static. ans d
Hi Kumar, I guess that by 'd' you mean '4'... 4. True. Local variables cannot be declared static, the "static" keyword being reserved for class variables declarations. The only modifier you may use in local variables declarations is "final". And access modifiers (private / protected / public) would not make any sense for local variables, because by nature, variables created on the stack are only accessible to the method they are declared in. 1. False. If defined, the first non-comment statement of the file is the "package" statement. 2. False. Private members of a class are only accessible from the class itself. 3. False. If an abstract class had to be declared as final, it could never be implemented. Regards, Phil.
Joined: Dec 16, 2003
hai Philippe, thank you very much, for the ans provided in detailed manner. with regards shyam