Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
janzon@gmail.com - 23 Feb 2007 21:42 GMT
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
Andrew Thompson - 23 Feb 2007 21:54 GMT
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.
Mark Rafn - 23 Feb 2007 22:26 GMT
>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/>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.