Can a Java program be both an applet and stand alone?

J

janzon

Howdy!

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...

/ Daniel
 
A

Andrew Thompson

On Feb 24, 8:42 am, (e-mail address removed) 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.
 
M

Mike Schilling

Andrew Thompson said:
On Feb 24, 8:42 am, (e-mail address removed) wrote:
..

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.
 
D

Daniel Dyer

On Feb 24, 8:42 am, (e-mail address removed) wrote:
..

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.
 
M

Mark Rafn

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.
 
J

janzon

On Feb 24, 8:42 am, (e-mail address removed) wrote:
..


Yes.

Do you got a reference to a document containing an example or a
description of how it works?
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).
 
O

Oliver Wong

Daniel Dyer said:
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.

Maybe that would have been the follow-up question had the interviewee
answered "yes".

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top