On Feb 24, 8:42 am, jan...@gmail.com wrote:
..
> I made a Java test at a job interview today. One of the questions was,
> "Can a Java program be both an applet and a stand alone program?". I
> had now idea, and I'm curious what the answer might be,
Yes.
>..and what the
> question is supposed to mean more exactly...
Why didn't you ask the interviewers?
Andrew T.
Mike Schilling - 23 Feb 2007 22:07 GMT
> On Feb 24, 8:42 am, jan...@gmail.com wrote:
> ..
[quoted text clipped - 3 lines]
>
> Yes.
And a JUnit test case, and a web service, and an ANT task, and a floor wax,
...
The point, I think, is that all of these require writing "entry-point"
methods that the environment running the program requires, and that these
methods will happily be ignored by other environments.
Daniel Dyer - 23 Feb 2007 22:14 GMT
> On Feb 24, 8:42 am, jan...@gmail.com wrote:
> ..
[quoted text clipped - 8 lines]
>
> Why didn't you ask the interviewers?
It's a rubbish interview question though. Assuming he got it right, how
do they know whether he knew it or he guessed? It would have been better
to have asked him to write a class that was both an application and an
applet.
Dan.

Signature
Daniel Dyer
https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
Oliver Wong - 23 Feb 2007 22:47 GMT
>> On Feb 24, 8:42 am, jan...@gmail.com wrote:
>> ..
[quoted text clipped - 13 lines]
> better to have asked him to write a class that was both an application
> and an applet.
Maybe that would have been the follow-up question had the interviewee
answered "yes".
- Oliver
janzon@gmail.com - 23 Feb 2007 22:46 GMT
> On Feb 24, 8:42 am, jan...@gmail.com wrote:
> ..
[quoted text clipped - 4 lines]
>
> Yes.
Do you got a reference to a document containing an example or a
description of how it works?
> >..and what the
> > question is supposed to mean more exactly...
>
> Why didn't you ask the interviewers?
Since the persons around were from management, not from the tech crew
(who were not in office; the interview was at eight O'Clock in the
morning).
Andrew Thompson - 23 Feb 2007 23:11 GMT
On Feb 24, 9:46 am, jan...@gmail.com wrote:
> > On Feb 24, 8:42 am, jan...@gmail.com wrote:
> > ..
> > > "Can a Java program be both an applet and a stand alone program?".
..
> > Yes.
>
> Do you got a reference to a document containing an example or a
> description of how it works?
Example code of one..
<http://groups.google.com/groups?selm=s3_Ch.
50778$Fi3.1181624@wagner.videotron.net>
Demo of another..
<http://www.physci.org/jws/#jtest>
Andrew T.
>I made a Java test at a job interview today. One of the questions was,
>"Can a Java program be both an applet and a stand alone program?". I
>had now idea, and I'm curious what the answer might be, and what the
>question is supposed to mean more exactly...
You're supposed to ask the interviewer what he means by a "Java program".
If he means an actual running instance of a VM, I can't think of a way to
get it to run both an applet and a main standalone entry point easily, but
it's probably possible with a lot of contortions.
If he means an entire codebase, the answer is a clear yes.
Just have different entry points for the Applet use and the standalone use
(and possibly multiple different classes for each - there's no reason not to
have 12 classes that are standalone starting points and another 4 that are
Applets).
If he means a single class, the answer is still yes. There's nothing to stop
a class that extends Applet to have a static void main(String[]) method.
--
Mark Rafn dagon@dagon.net <http://www.dagon.net/>