some java questions.

H

hardik

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

Thomas Hawtin

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
 
B

BlueOpal

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";]
 
A

Alex Hunsley

hardik said:
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?

How do you expect to learn anything if you get others to answer your
homework?
This isn't the homework dropin service.
 
A

Alex Hunsley

BlueOpal said:
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";]

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

Bjorn Abelli

BlueOpal said:
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";]

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

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
 
D

Darryl L. Pierce

hardik said:
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
 
D

Darryl L. Pierce

Bjorn said:
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*.
 
N

newsnet customer

BlueOpal said:
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";]

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.

ST
 
M

Mitch

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

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

Greg R. Broderick

[posted and mailed]

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?

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

Regards
GRB

--
---------------------------------------------------------------------
Greg R. Broderick [rot13] (e-mail address removed)

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

Roedy Green

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

Alex Hunsley

newsnet said:
BlueOpal said:
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";]
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.

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!)
 
T

trippy

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?

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

Eric Sosman

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

Oliver Wong

[Alex wrote:]
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
 
L

Luc The Perverse

Oliver Wong said:
[Alex wrote:]
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.

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

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,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top