Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

corrections in marcus green test1

 
Bob Mathews
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all

i have just appeared in the marcus green test no 1.
11 questions were not in the current sylabus for scjp1.4

And question 59 says

class Base{
private void amethod(int iBase){
System.out.println("Base.amethod");
}
}
class Over extends Base{
public static void main(String argv[]){
Over o = new Over();
int iBase=0;
o.amethod(iBase);
}
public void amethod(int iOver){
System.out.println("Over.amethod");
}
}
1) Compile time error complaining that Base.amethod is private
2) Runtime error complaining that Base.amethod is private
3) Output of "Base.amethod"
4) Output of "Over.amethod
Answer :4

but i think Answer should be compile time error as none of the classes are public

correct we if i m wrong

And i have scored 41 correct of those 49 questions 84% roughly

what u ranchers suggest ?

regards
Nishant
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I compiled and ran it to get Over.amethod. None of your classes need to be public. The rule is that if a class is public it must have the same name as the file name and no more than one public class is allowed per file.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice that the second amethod is inside the definition of Over.
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two points,
It says very clearly in large letters at the top of the exam
"This exam is based on the objectives of the JDK 1.2 exam.
You can see set of 60 questions for the JDK1.4 exam at JDK1.4 Exam"
(with hyperlink to http://www.jchq.net/phezam.


The other is that when you come accross an issue such as this you are best advised to compile the code yourself to see what happens. Javac is the best friend of the exam candidate.

Your feedback is appreciated, keep posting
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic