• 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

Ques from Jxam

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are 2 Ques. fom JExam about which i have doubt.

Which of the following statements are true regarding inner classes.
Possible Answers:
-------------------
Possible Answer 1:
Variables defined inside inner classes cannot be static.

Possible Answer 2:
Variables defined inside inner classes cannot be static unless the inner class itself is static.

Possible Answer 3:
Non-static inner classes (which are not defined in a method) have access to all class and instance variables, regardless of the access qualifier of those variables.
Possible Answer 4:
An inner class can actually be a subclass of the outer class

Possible Answer 5:
Inner classes can be declared as private. Top level, outer classes cannot.
Correct answer given is 2 whereas i think 1 is also correct as they
themselves has explained in 2.
The argument for a "case" statement must be a constant or a constant expression which can be evaluated at compile time.
Possible Answers:
-------------------
Possible Answer 1:
True

Possible Answer 2:
False

Correct Answer...
-----------------
Answer 1:
True
I think correct answer is false because constant or constant expression
should not be long float,double,boolean.They should have explicitly
mention it.
Please express your views.
Thankx.
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
question 1) i say answers 3, 4, and 5 are correct. As for answers 1 and 2, the fact is that non-static inner classes can have static members if those members are also final.
question 2) the fact that the argument for a case statement must be assignable to int does not make the statement that it must be a constant false.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ashish r u of TIL?What book u r following for inner class?
 
Ashish Agarwal
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for placing my Question wrong. Actually what I wanted to ask was if in Q1 choice 2 is correct than choice 1 is also true.Choice 3,4,5 are obviously true.Indeed they have given choices 2,3,4,5 as true.
Once again sorry for miscommunication.
Randall can you explain it with a example.
Thanks.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic