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 / April 2006

Tip: Looking for answers? Try searching our database.

some java questions.

Thread view: 
hardik - 16 Apr 2006 10:25 GMT
1)  A java source file can contain How many public classes ?

2)  What is default  layout of  Frame and Applet?

3)  References are always passed by ___ ?

4)  Which class doesn't call its super class constructor?
BlueOpal - 16 Apr 2006 10:49 GMT
1)  A java source file can contain How many public classes ? [All the
classes can be public]

2)  What is default  layout of  Frame and Applet? [BorderLayout]

3)  References are always passed by ___ ? [Objects are always passed by
reference(address). Primitives are passed by Value]

4)  Which class doesn't call its super class constructor? [String str =
"abc";]
Thomas Hawtin - 16 Apr 2006 10:25 GMT
I hope you are taking the piss with these answers?

hardik> Where did they come from? Hope they aren't homework.

Anyway, in the interests of correct information (please correct me if I
make any mistakes):

> 1)  A java source file can contain How many public classes ? [All the
> classes can be public]

A Java source file can contain only one public outer class, because the
names of public classes must match their source file names. However, it
can contain many public nested classes.

I wouldn't generally recommend putting "package private" classes in
sources files with a different name. OTOH, some hacks require an outer
class which only has to do with the implementation of one significant
class. For instance, initialising "transient" final variables of
serialisable classes (without using sun.misc.Unsafe).

> 2)  What is default  layout of  Frame and Applet? [BorderLayout]

Even so I'd tend to set a layout explicitly. Just as well to be
explicit. And Panel defaults to a different layout manager (as does Box...).

> 3)  References are always passed by ___ ? [Objects are always passed by
> reference(address). Primitives are passed by Value]

References are always passed by value, technically. Everything is passed
by value. Objects are always referred to by references.

> 4)  Which class doesn't call its super class constructor? [String str =
> "abc";]

String str = "abc"; does not involve a constructor. It merely obtains a
reference to a preexisting constant object.

java.lang.Object does not call its super class constructor, because it
is the only class without a super class. OTOH, you could arrange for a
constructor to throw an exception before super is called, or do
something that does not exit at all.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Alex Hunsley - 16 Apr 2006 11:38 GMT
> 1)  A java source file can contain How many public classes ? [All the
> classes can be public]
[quoted text clipped - 6 lines]
> 4)  Which class doesn't call its super class constructor? [String str =
> "abc";]

Please don't just answer people's drive-by homework assignments for
them. This is obviously just the guys homework. How is doing his
homework for him going to help him?
Bjorn Abelli - 16 Apr 2006 11:43 GMT
"Alex Hunsley" wrote...
>> 1)  A java source file can contain How many public classes ? [All the
>> classes can be public]
[quoted text clipped - 10 lines]
> This is obviously just the guys homework. How is doing his homework for
> him going to help him?

In this case it maybe *would* help him, as most of the answers BlueOpal
provided were wrong...

If the OP hands in those answers, the teacher would flunk him, and he'll
learn to not let anyone else do his homework again... ;-)

// Bjorn A
Darryl L. Pierce - 16 Apr 2006 13:50 GMT
>> Please don't just answer people's drive-by homework assignments for them.
>> This is obviously just the guys homework. How is doing his homework for
>> him going to help him?
>
> In this case it maybe *would* help him, as most of the answers BlueOpal
> provided were wrong...

And maybe, just maybe, BlueOpal gave those answers in case the OP is *NOT*
looking for help and is just looking to get free answers to homework. If
the OP turns in homework with those answers, s/he'll have hell to pay with
the instructor.

> If the OP hands in those answers, the teacher would flunk him

As would be deserved for trying to *CHEAT*.

Signature

Darryl L. Pierce <mcpierce@gmail.com>
http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"

newsnet customer - 16 Apr 2006 14:17 GMT
> > 1)  A java source file can contain How many public classes ? [All the
> > classes can be public]
[quoted text clipped - 10 lines]
> them. This is obviously just the guys homework. How is doing his
> homework for him going to help him?

Alex, please dont tell people what they can or can't do.

ST
Mitch - 16 Apr 2006 14:31 GMT
[snip]
>> Please don't just answer people's drive-by homework assignments for
>> them. This is obviously just the guys homework. How is doing his
[quoted text clipped - 3 lines]
>
> ST

Perhaps it is me, but I read any sentence that starts with 'please' as a
request rather than an instruction.

"pass me the salt" = instruction,

"please pass me the salt" = request.

You may see this differently as many people in authority, for
politeness' sake, say "please do this for me" when what they mean is "do
this for me".  This doesn't detract from the different meanings though.

/************/

For what is an international medium there are many scraps on Usenet that
are based on the subtleties of language.  It's interesting to watch it
unfold...

Mitch.

disclaimer:  These are opinions, and I haven't gone to the trouble of
checking my dictionary (though as British, who knows if my version our
version of the English language counts any more).  Also, I haven't
directed this at any particular party.  You are free to publish any
opinions on this matter and I promise to take them, at least, with a
pinch of salt.
Luc The Perverse - 16 Apr 2006 18:32 GMT
>> Please don't just answer people's drive-by homework assignments for
>> them. This is obviously just the guys homework. How is doing his
>> homework for him going to help him?
>
> Alex, please dont tell people what they can or can't do.

Um . . . Here's your sign?

--
LTP

:)
Roedy Green - 16 Apr 2006 19:40 GMT
On Sun, 16 Apr 2006 13:18:21 GMT, "newsnet customer"
<customer@newsnet.com> wrote, quoted or indirectly quoted someone who
said :

>> Please don't just answer people's drive-by homework assignments for
>> them. This is obviously just the guys homework. How is doing his
>> homework for him going to help him?
>
>Alex, please dont tell people what they can or can't do.

That is not what he did. He simply requested people not to do newbie's
homework and explained why he was making that request. He even said
please.

I think the consensus here is you should not baby newbies.  You might
give hints or encouragement, or answer specific questions, but you
should never simply do the homework for a newbie.  It robs him of his
education, even if he is too foolish to see that.  See
http://mindprod.com/jgloss/homework.html where I elaborate on that
argument.

The general request not to tell people what they can or cannot do is a
bit ridiculous. That is what learning to program is all about,
learning what you can and cannot do, and what is considered the best
way to do things.

If you do newbie's homework for them, look at what your motive might
be?

1. ability to show off a little by answering easy questions nobody
else takes a kick at?

2. the gratitude of the foolish newbie?

3. something prevented you from caring for infants to the point of
saturation at some point in your life?  You enjoy caring for the young
and apparently helpless.

4. hoping for a little extra cash from lazy but well heeled students?

5. to appear kind-hearted?

It is like the old fight been grandparents and parents with the
grandparents wanting to spoil the kids, even if it teaches them bad
habits and rots their teeth.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Alex Hunsley - 16 Apr 2006 20:11 GMT
>>> 1)  A java source file can contain How many public classes ? [All the
>>> classes can be public]
[quoted text clipped - 11 lines]
>
> Alex, please dont tell people what they can or can't do.

It's a request (see "please"), not a 'tell', and it's a request made for
a good reason.

There's a good reason for requesting what people do. This group (and
others) maintain a certain standard, and that standard exists because
regulars give feedback. One of the reasons people like yourself can come
and request help, and get decent help, is because people don't tend to
allow the group to become a mire of homework questions and nonsense,
which would push away the regulars/experienced ones.

Every now and then someone fairly new to the group answers what appears
to be an obvious case of a homework question pasted straight into the
group. This can be counter productive.
Do you really want to sit in a newsgroup where lazy people just come by
and paste their homework questions verbatim and get them answered? How
are they going to learn much that way?

Check out Roedy Green's page on homework in the Java glossary.
http://mindprod.com/jgloss/homework.html

(It looks like the first replier to the homework question pasted a load
of nonsense, mind you!)
Oliver Wong - 17 Apr 2006 18:20 GMT
[Alex wrote:]

>> Please don't just answer people's drive-by homework assignments for
>> them.
>
> Alex, please dont tell people what they can or can't do.

   I took this to be an ironic statement showing the futility of asking
(politely or otherwise) people on Usenet to do behave a certain way. If Alex
continues "telling" (requesting?) people not to do something, it just
further highlights the futility.

   Not sure if this was "newsnet customer"'s intent.

   - Oliver
Luc The Perverse - 17 Apr 2006 21:29 GMT
> [Alex wrote:]
>>>
[quoted text clipped - 9 lines]
>
>    Not sure if this was "newsnet customer"'s intent.

Yes I thought the irony was obvious and apparent, if not deliberate.  Hence
my "Here's Your Sign" comment.

--
LTP

:)
Alex Hunsley - 16 Apr 2006 11:36 GMT
> 1)  A java source file can contain How many public classes ?
>
[quoted text clipped - 3 lines]
>
> 4)  Which class doesn't call its super class constructor?

How do you expect to learn anything if you get others to answer your
homework?
This isn't the homework dropin service.
Darryl L. Pierce - 16 Apr 2006 13:48 GMT
> 1)  A java source file can contain How many public classes ?

8 on a 32-bit machine, 16 on a 64-bit machine.

> 2)  What is default  layout of  Frame and Applet?

BorderLayout.CENTER.

> 3)  References are always passed by ___ ?

The invoking code.

> 4)  Which class doesn't call its super class constructor?

null

Signature

Darryl L. Pierce <mcpierce@gmail.com>
http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"

Thomas Kellerer - 16 Apr 2006 13:58 GMT
Darryl L. Pierce wrote on 16.04.2006 14:48:
>> 3)  References are always passed by ___ ?
>
> The invoking code.

Brilliant :)
Greg R. Broderick - 16 Apr 2006 17:18 GMT
[posted and mailed]

"hardik" <hardikdangar@gmail.com> wrote in news:1145179502.775033.119330
@u72g2000cwu.googlegroups.com:

> 1)  A java source file can contain How many public classes ?
>
[quoted text clipped - 3 lines]
>
> 4)  Which class doesn't call its super class constructor?

Answers to all of your questions may be found at <http://www.catb.org/
~esr/faqs/smart-questions.html#homework>.

Regards
GRB

Signature

---------------------------------------------------------------------
Greg R. Broderick                 [rot13] terto@oynpxubyvb.qlaqaf.bet

A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------

trippy - 17 Apr 2006 02:30 GMT
> 1)  A java source file can contain How many public classes ?

1 main class and 1 anonymous inner class, IIRC.

> 2)  What is default  layout of  Frame and Applet?

I...I don't know.

> 3)  References are always passed by ___ ?

reference.

> 4)  Which class doesn't call its super class constructor?

Servlet?

Signature

trippy
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Rhythm From A Red Car" -- Hardline

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum, a pocketknife,
and a smile."

-- Robert Redford "Spy Game"

Eric Sosman - 17 Apr 2006 15:14 GMT
hardik wrote On 04/16/06 05:25,:
> 1)  A java source file can contain How many public classes ?

   As many as you like.  At some point you'll probably
run into practical limitations imposed by the .class file
format, but Java itself places no specific limit.

> 2)  What is default  layout of  Frame and Applet?

   Nobody uses them any more, so why worry?

> 3)  References are always passed by ___ ?

   ... one hand to another.  For security, always wash
your hands before and after passing a reference.

> 4)  Which class doesn't call its super class constructor?

   The one you are about to fail.

Signature

Eric.Sosman@sun.com



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.