• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

is this a proper mock question for the exam?

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic