Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock test true or flase

 
Sham Grandhe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

thanking you
shyam
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sham Grandhe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai Philippe,
thank you very much, for the ans provided in detailed manner.
with
regards
shyam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic