Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

subClass methods ?  RSS feed

 
R K Singh
Ranch Hand
Posts: 5390
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is a Que from Maha's mock test
33. Consider the classes defined below:

Which of the following are legal method declarations to add to the class Sub? Assume that each method is the only one being added.
a) public static void main( String args[] ){}
b) float methodTwo(){}
c) long methodOne( int c, long d ){}
d) int methodOne( int c, long d ) throws ArithmeticException{}
e) int methodOne( int c, long d ) throws FileNotFoundException{}
I think answer is
a) as it is our pet main() method
b) as it is overloading super class's method
d) as it is throwing unchecked Exception and I checked it it compiles fine.
e) as FileNotFoundException is subClasss of IOE.
AND
c) can not be as return type is different.
but evalution page says that ans is WRONG.. and page which contains answer is not available.
so plz ane1 can tell what is the answer for the above question
CMIW
TIA
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lets leave this one for Valentin or Rob to answer but im with u Kumar on this one .
c is wrong the rest are correct in my opinion.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How kind of you Roy
You got the right answers...
Anyone else?
 
R K Singh
Ranch Hand
Posts: 5390
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Valentin Crettaz:

You got the right answers...

Hi Val
then why it is giving WRONG
coz my other que, also I was thinking that answer might be wrong(Errata) but after discussing here I found that I was wrong.... Though I still say that above given ans is correct in my knowledge but then WHY it is giving "WRONG"???
TIA
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It says WRONG because because you don't have all right answers. Let's say correct answers are a, b and c. If you don't answer that, then the verdict will be WRONG, that is even if you answer a,b,c,d you'll get wrong...
Now from what I see in the HTML page source code, the correct answers are a,b and e. So I don't know why she doesn't count d as a correct option...
Anyone else ?
 
R K Singh
Ranch Hand
Posts: 5390
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so we can assume it to be error ... what ever Typo, etc....
so ans is a b d e
CMIW
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!