• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

gEs demo - question on valid inner class

 
Linda Xu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this question in ge is mock exam:
Given the following class definition:
Class A {
protected int i ;
A( int i) {
this.i = i;
}
}
which of the following will be a valid inner class for this class?
...
C.
class B {
B() {System.out.println("i=" +i);}
}
The answer said the above is not a correct answer. But I tried to compile, it compile and run without any exception?
What's wrong? ge give the wrong answer?
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Linda,
For the given class, the given inner class is valid. What I think is there may be someother information you would have forgotten to post. I am not sure. Can you post the exact qstn from the Exam?
The given code will produce two .class files in the current dir where it is compiled if no other redirection option is given while compiling. They are 1. A.class 2. A$B.class
regds
maha anna
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like the exam question is wrong. What is the URL for this "ge is mock exam"? And does this question have a number?
 
Linda Xu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, there is a typo about the exam name. It's the gE's mock exam. I downloaded the evaluation edition. There is 15 questions in it.
About this question, the question body is like my first post. There is fives items for multi select, because I understand other four, I omit them. The C item is exactly as I posted.
So, the C should be right answer here?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup. I'll move this to Mock Exam Errata so others can find it in the future. Thanks.
 
Javix Protocol
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also attende that exam and i suppose that what xu i s telling is correct.
Can maha anna caretake this affair properly?
 
Larry LeFever
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
doesn't "i" need to be final in order for the nested class to reference it?
 
Larry LeFever
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops.
that's only for locals and args, right?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic