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.
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.
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.