Advertisements

Jerry wrote:
> If you make a call to the database.
>
> If you cannot find any person with a matching last name, do you
>
> a. Return null
>
> b. Throw a RuntimeException
>
> c. Other (what will you do?)
>
> Thanks a lot!

Why don't you just airmail me the whole questions form and I will answer
all your homework questions for you at only 100 USD an hour.

Advertisements

> If you make a call to the database.
> If you cannot find any person with a matching last name, do you
>
> a. Return null
> b. Throw a RuntimeException
> c. Other (what will you do?)

Depends upon the task. If the person should be in the database I would use
b. If it is likely that the person is not in the database then I would use
a.

a will allow the execution to continue allowing the application to create
the person in the database.
b will jump out of the execution to an exception handler, that will
typically show a message to the user why the operation failed.

"Niels Dybdahl" <> wrote in message
news:4296e78b$0$339$...
> > If you make a call to the database.
> > If you cannot find any person with a matching last name, do you
> >
> > a. Return null
> > b. Throw a RuntimeException
> > c. Other (what will you do?)
>
> Depends upon the task. If the person should be in the database I would use
> b. If it is likely that the person is not in the database then I would use
> a.
>
> a will allow the execution to continue allowing the application to create
> the person in the database.
> b will jump out of the execution to an exception handler, that will
> typically show a message to the user why the operation failed.
>
> Niels Dybdahl

I assume the question refers to how your code would handle the fact that
there were no results in the ResultSet (detected when ResultSet.first()
returns false).

And I think it really depends on the context of the code.

If it's a job interview question, then probably the only answer is: it's
not what you answer, it's how you answer.

(I've read that even wrong answers delivered thoughtfully will impress
an interviewer, whereas a right answer delievered quickly and without
thought will turn off the interviewers. For the record, I hate job
interviewers.)
--
Bob

On Fri, 27 May 2005 17:06:41 +0800, jonck wrote
(in article <>):
>> If you make a call to the database.
>
>> If you cannot find any person with a matching last name
>
> This will give you an empty ResultSet.
>

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!