| 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 <br />SCJP 1.4, SCWCD 1.4<br /><a href="http://www.pazbrasil.org/" target="_blank" rel="nofollow">http://www.pazbrasil.org/</a>
|
 |
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: 3829
|
|
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: 1348
|
|
#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.
|
 |
 |
|
|
subject: Question from go4java mock
|
|
|