Author Topic:   true/false
Umesh
ranch hand
posted April 14, 2000 10:52 PM             
Question from gES:

Which of the following statements are true?

A. A method cannot be overloaded to be less public in a child class
B. To be overriden a method must have the same name and parameter
types
C. To be overriden a method must have the same name, parameter
and return types //ans
D. An overriden method must have the same name, parameter names
and parameter types

My answer is B. I hope return type is not the part of overriding signature.

satya5
ranch hand
posted April 14, 2000 11:22 PM             

That is not true. Return type is a part of the
overriding signature.
The following is a quotation from RH on method
overriding ...

* Overriding methods must have argument lists of
identical type and order.
* The return type of an overriding method must be
identical to that of the method it overrides.

Hope this helps.

- satya

Prabhpreet
unregistered
posted April 14, 2000 11:39 PM           
quote:
Originally posted by Umesh:
Question from gES:

Which of the following statements are true?

A. A method cannot be overloaded to be less public in a child class
B. To be overriden a method must have the same name and parameter
types
C. To be overriden a method must have the same name, parameter
and return types //ans
D. An overriden method must have the same name, parameter names
and parameter types

My answer is B. I hope return type is not the part of overriding signature.



The correct answer is C

girish
greenhorn
posted April 15, 2000 04:57 AM             
Correct me if I am wrong
What I feel is ans b is also one of the choices since it says the overridden method must have same name & parameter list this is true . Isn't it? If the question asks :

Which statements(not statement) are true.

maha anna
bartender
posted April 15, 2000 08:43 AM             
girish,
You are making sense. But what I think is , eventhough and b) as such is true, when you select the ans c) it means ans b) also right?. ans b) is a sub-set of ans c). So while answering we try to not to duplicate answers. Any way I think (hope ) in real exam the wording will more clearer and more specific.
regds
maha anna

Jim Yingst
sheriff
posted April 15, 2000 01:28 PM             
Umesh- no, return type is not part of the signature, but that's not what option C says. It says that the return type must be the same (regardless of whether it's part of the signature, which it isn't). This is true.

Maha- we agree C contains B, but I think that if the question allows multiple answers, we should select all that are true - B and C in this case. If the question only allows one answer, then C is the best one.

maha anna
bartender
posted April 15, 2000 01:35 PM             
Jim,
You are back. . I was answering the post half-hearted. What's expected? Why do they test like this?
regds
maha anna

Jim Yingst
sheriff
posted April 15, 2000 06:33 PM             
Well, in the written question it's not necessarily clear if multiple answers are accepted. When running the gEs simulator though you can always try entering multiple answers - if it works, then multiple answers are allowed. If not, choose the best single answer.

I'm not sure why the test format has multiple-answer questions like this - it is rather unusual among tests. Maybe they wanted to make the questions harder?

Ihor Srutynskyj
unregistered
posted April 17, 2000 12:58 AM           
Here are my 0.02c in support of Umesh's answer.
Answer B is WIDER than C, and C is more restrictive than B, hence
C is a subset of B (not: B is a subset of C), and B contains C (not: C contains B). Since both answers are correct but C is narrower than B, then correct answer should be B if only one answer is expected.

(Could not get the javaranch.com recognize my user name from my home PC)

Sanath Kumar
greenhorn
posted April 17, 2000 04:47 AM             
My vote is for C but not for B.

as stated by Satya.

* Overriding methods must have argument lists of identical type and order.
* The return type of an overriding method must be identical to that of the method it overrides.

B doesn't specify the return type but in C it is clearly specified about the return type.

So B is a subset of C and B is lacking in Return type. So C would be the best choice.

-Sanath

[This message has been edited by Sanath Kumar (edited April 17, 2000).]

maha anna
bartender
posted April 17, 2000 11:07 AM             
Ihor Srutynskyj,
What I said about which is sub-set of which, and which answer contains the other answer is infact correct. And your post is wrong in that sense. Ok . FYI I didn't edit my previous post also as you can see. Also remember that this is not the topic to discuss. The main discussion as we all agree ans c) which says return type/method name /parameter is more suitable in overriding context. Ok. As Jim said if the qstn asks for more than 1 ans then probably we have to think of if we select ans b) also.
regds
maha anna

[This message has been edited by maha anna (edited April 17, 2000).]

|