File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is this a proper mock question for the exam?

 
gianni ipez
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I'm doing several mock exams.
Could be the following one be a proper mock question for the exam?


Which of the following declarations of robustMethod(int[] intArray) are valid in a subclass of the above class?

a) public void robustMethod(int[] intArray)
b) public void robustMethod(int[] intArray) throws Exception
c) public void robustMethod(int[] intArray) throws Throwable
d) public void robustMethod(int[] intArray) throws Error
e) public void robustMethod(int[] intArray) throws RuntimeException

I studied that it's not usual to throw errors, so I think this question is a bit misleading. Am I right?
Is it possible to get questions like this?
By the way the answer is
a),d),e)

Thanks,
Gianni
 
Srinivasan thoyyeti
Ranch Hand
Posts: 557
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gianni,

Gianni:I studied that it's not usual to throw errors, so I think this question is a bit misleading. Am I right?


1.There is no need to bother about Errors or RuntimeExceptions.
1.1 Parents and Child methods can optionally declare RuntimeExceptions or Errors of their own.

2.Coming to checked-exceptions:
1.1 If parent methd has one, then
1.1.1 Child method may or may not throw that exeption
1.1.2 Child method should not declare any additional exceptions.

Hope it helps you avoid ambiguity.
[ April 02, 2007: Message edited by: Srinivasan thoyyeti ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic