aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question from go4java mock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question from go4java mock" Watch "Question from go4java mock" New topic
Author

Question from go4java mock

Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Which one of the following methods will give you an error when placed at
line no.10? Select one correct answer.



Options for answer:
1. public final void callme(){}
2. void callMe(){}
3. void callme(int a){}
4. void callme(){}


None of this options generated an error in my jdk (1.4). Can anyone clearify this to me?


Leandro Melo
SCJP 1.4, SCWCD 1.4
ramaseshan T
Ranch Hand

Joined: Feb 17, 2005
Posts: 30


1. public final void callme(){}
2. void callMe(){}
3. void callme(int a){}
4. void callme(){}


None of this options generated an error in my jdk (1.4). Can anyone clearify this to me?


1. Way to override callme method - No compiler error
2. Note "M" in callMe - It is a overloaded method - No error
3. Again it is perfect overloading - No error
4. Generates compiler error in JDK 1.4 - since it is declared with lesser access previleges

Please correct me if I am wrong...


Ramaseshan T<br />SCJP 1.4
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by ramaseshan T:


2. Note "M" in callMe - It is a overloaded method - No error
Please correct me if I am wrong...



It is not overloading method , it is whole together new method .
everything else is right .
Charles Chen
Greenhorn

Joined: May 30, 2004
Posts: 5
Originally posted by Leandro Melo:
Which one of the following methods will give you an error when placed at
line no.10? Select one correct answer.



Options for answer:
1. public final void callme(){}
2. void callMe(){}
3. void callme(int a){}
4. void callme(){}


None of this options generated an error in my jdk (1.4). Can anyone clearify this to me?


I will say no.4. I think it is not a overload method nor override method.
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
#4 gives compiler error for me:

C:\_Work\java>javac A.java
A.java:10: callme() in B cannot override callme() in A; attempting to assign weaker access privileges; was public
void callme(){}
^
1 error

C:\_Work\java>java -version
java version "1.4.1_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_05-b01)
Java HotSpot(TM) Client VM (build 1.4.1_05-b01, mixed mode)
Kedar Dravid
Ranch Hand

Joined: May 28, 2004
Posts: 333
The answer to the question is option no.4, because we are trying to override the callme() method with a weaker access privilege. Period.
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Sorry, of course it generates a error. I tested it wrong.
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question from go4java mock