• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Non Static Innerclass

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Non static inner classes do not contain static members but if we declare something like final static int i=10; ie static with final then there is no problem. Different mock exams gives different answers for these questions.
Question :
1.Non static inner classes do not contain static members (T/F) ?
2.Both static and non-static inner classes can contain static
members (T/F) ?
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends on whether the author of the exam was mentally making a special case out of the "private static" cases.
Mock exams are only as good as the author. Even the big time Java books have errata tracking to clean up little inconsistancies like that.
 
Ishaan Mohan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cindy,
So if this question comes in SCJP2
Non static inner classes can contain static members.
then I supposed to say No(False), am I right ?
 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say that they can't contain static members because(!!) when you place final compiler treats it differently. It treats it as a constant. So the variable and a constant are not too same things it's my opinion on it.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that you will find that on the exam they avoid the confusion caused by exact wording of dicey questions by not asking it that way. Instead they would probably show some code with a static final variable in an Inner class and ask if it will compile (or something like that).
The questions on the exam have been screened and scrutinized and talked over minutely. They are very clear if you read them carefully. Much more "confusion free" than many of the questions on the Mocks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic