Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Can a Java program be both an applet and stand alone?

Reply
Thread Tools

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

 
 
janzon@gmail.com
Guest
Posts: n/a
 
      02-23-2007
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

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      02-23-2007
On Feb 24, 8:42 am, (E-Mail 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.

 
Reply With Quote
 
 
 
 
Mike Schilling
Guest
Posts: n/a
 
      02-23-2007

"Andrew Thompson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> On Feb 24, 8:42 am, (E-Mail 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 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.


 
Reply With Quote
 
Daniel Dyer
Guest
Posts: n/a
 
      02-23-2007
On Fri, 23 Feb 2007 21:54:46 -0000, Andrew Thompson
<(E-Mail Removed)> wrote:

> On Feb 24, 8:42 am, (E-Mail 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?


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.

--
Daniel Dyer
https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
 
Reply With Quote
 
Mark Rafn
Guest
Posts: n/a
 
      02-23-2007
<(E-Mail 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, 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 http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.dagon.net/>
 
Reply With Quote
 
janzon@gmail.com
Guest
Posts: n/a
 
      02-23-2007
On 23 Feb, 22:54, "Andrew Thompson" <(E-Mail Removed)> wrote:
> On Feb 24, 8:42 am, (E-Mail 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.


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


 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      02-23-2007

"Daniel Dyer" <"You don't need it"> wrote in message
news(E-Mail Removed)...
> On Fri, 23 Feb 2007 21:54:46 -0000, Andrew Thompson
> <(E-Mail Removed)> wrote:
>
>> On Feb 24, 8:42 am, (E-Mail 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?

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


 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      02-23-2007
On Feb 24, 9:46 am, (E-Mail Removed) wrote:
> On 23 Feb, 22:54, "Andrew Thompson" <(E-Mail Removed)> wrote:
> > On Feb 24, 8:42 am, (E-Mail Removed) 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$(E-Mail Removed)>
Demo of another..
<http://www.physci.org/jws/#jtest>

Andrew T.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Groovy be used in an applet and/or can it generate the Java bytecodes that then can be used in an applet? Casey Hawthorne Java 1 03-18-2009 12:56 AM
Transforming an applet into a stand-alone Java program freeposte Java 7 02-10-2006 04:14 AM
stand alone executable using pp doesn't stand alone Plotinus Perl Misc 2 12-17-2004 01:09 AM
Java applet failed when I try to load the avi file in my java applet Krista Java 3 09-15-2004 02:53 AM
image on applet/stand-alone program Java 1 09-12-2003 02:29 PM



Advertisments