Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #476 > unrolled thread

Class ... implements ...

Started byMerciadri Luca <Luca.Merciadri@student.ulg.ac.be>
First post2011-04-02 22:13 +0200
Last post2011-04-06 12:08 -0400
Articles 20 on this page of 37 — 8 participants

Back to article view | Back to comp.lang.java.help


Contents

  Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-02 22:13 +0200
    Re: Class ... implements ... Lew <noone@lewscanon.com> - 2011-04-02 17:30 -0400
      Re: Class ... implements ... Roedy Green <see_website@mindprod.com.invalid> - 2011-04-02 23:09 -0700
      Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 12:00 +0200
    Re: Class ... implements ... Roedy Green <see_website@mindprod.com.invalid> - 2011-04-02 20:53 -0700
      Re: Class ... implements ... Stanimir Stamenkov <s7an10@netscape.net> - 2011-04-03 10:15 +0300
    Re: Class ... implements ... Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-03 08:42 -0400
      Re: Class ... implements ... Roedy Green <see_website@mindprod.com.invalid> - 2011-04-03 06:45 -0700
        Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 17:29 +0200
          Re: Class ... implements ... Patricia Shanahan <pats@acm.org> - 2011-04-03 09:01 -0700
            Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 18:10 +0200
              Re: Class ... implements ... Patricia Shanahan <pats@acm.org> - 2011-04-03 09:32 -0700
                Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 18:48 +0200
          Re: Class ... implements ... Aéris <aeris@imirhil.fr> - 2011-04-03 18:07 +0200
            Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 18:22 +0200
              Re: Class ... implements ... Aéris <aeris@imirhil.fr> - 2011-04-03 19:02 +0200
                Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 20:15 +0200
        Re: Class ... implements ... Lew <noone@lewscanon.com> - 2011-04-06 12:01 -0400
      Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 17:27 +0200
        Re: Class ... implements ... Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-03 14:26 -0400
        Re: Class ... implements ... Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-04-03 16:14 -0300
          Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 21:33 +0200
            Re: Class ... implements ... Aéris <aeris@imirhil.fr> - 2011-04-03 22:13 +0200
              Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 22:24 +0200
        Re: Class ... implements ... Lew <noone@lewscanon.com> - 2011-04-06 12:05 -0400
      Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 17:31 +0200
        Re: Class ... implements ... Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-03 14:41 -0400
          Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 21:45 +0200
            Re: Class ... implements ... Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-03 16:40 -0400
              Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 22:58 +0200
                Re: Class ... implements ... Lew <noone@lewscanon.com> - 2011-04-06 12:13 -0400
            Re: Class ... implements ... Lew <noone@lewscanon.com> - 2011-04-06 12:10 -0400
          Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 21:51 +0200
            Re: Class ... implements ... Patricia Shanahan <pats@acm.org> - 2011-04-03 13:02 -0700
              Re: Class ... implements ... Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-03 22:23 +0200
            Re: Class ... implements ... Lew <noone@lewscanon.com> - 2011-04-06 12:15 -0400
        Re: Class ... implements ... Lew <noone@lewscanon.com> - 2011-04-06 12:08 -0400

Page 1 of 2  [1] 2  Next page →


#476 — Class ... implements ...

FromMerciadri Luca <Luca.Merciadri@student.ulg.ac.be>
Date2011-04-02 22:13 +0200
SubjectClass ... implements ...
Message-ID<87vcywpg2h.fsf@merciadriluca-station.MERCIADRILUCA>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm given the following program snippet:

==
class C1
{
 public int n;
}

interface I1
{
 int f();
}

class C2 extends C1 implements I1
{
 public int f()
 {
  n = 18;
 }
}
==
I need to say if the following expressions are valid or not
(justifications are trivial once I'm sure of the answer):

1. C1 obj_1 = new C2();
2. C2 obj_2 = new C1();
3. I1 obj_3 = new C2();
4. I1 obj_4 = new I1();
5. C2 obj_5 = new I1();

I've found that 1. and 3. are valid, when the others (2., 4. and 5.)
are invalid. Am I right?

Thanks.
- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

Don't try to teach a pig to sing. It doesn't work, and you'll annoy
  the pig. 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2Xg2YACgkQM0LLzLt8MhyAvQCgkfvvu0gYCHyzgRpl3Xj4cUpG
CSAAmwR19jvbbHTyCfSPLRXti8PvPSBa
=Fu/s
-----END PGP SIGNATURE-----

[toc] | [next] | [standalone]


#482

FromLew <noone@lewscanon.com>
Date2011-04-02 17:30 -0400
Message-ID<in84h3$fa3$1@news.albasani.net>
In reply to#476
Merciadri Luca wrote:
> I'm given the following program snippet:
>
> ==
> class C1
> {
>   public int n;
> }
>
> interface I1
> {
>   int f();
> }
>
> class C2 extends C1 implements I1
> {
>   public int f()
>   {
>    n = 18;
>   }
> }
> ==
> I need to say if the following expressions are valid or not
> (justifications are trivial once I'm sure of the answer):

Sure, it is an awful lot easier to do your homework once someone has given you 
the answers.  We know.

But it seems rude that you ask for answers to your homework and haven't even 
tried to do the research yourself first.  Maybe somewhat more actionable than 
rude, even.

Perhaps if you tell us first what you are thinking or trying, it will help 
counteract that unfortunate impression that you are trying to, ahem, cut corners.

> 1. C1 obj_1 = new C2();
> 2. C2 obj_2 = new C1();
> 3. I1 obj_3 = new C2();
> 4. I1 obj_4 = new I1();
> 5. C2 obj_5 = new I1();
>
> I've found that 1. and 3. are valid, when the others (2., 4. and 5.)
> are invalid. Am I right?

Which expressions put a subtype instance into a supertype variable?

Which expressions put a supertype instance into a subtype variable?

How can a subtype variable be sure that a supertype instance is of the correct 
type?

Are you allowed in Java to instantiate an interface?

Please answer as best you can.  You should use the Java tutorials to help you; 
don't just randomly guess.  We will be expecting your responses.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#488

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-04-02 23:09 -0700
Message-ID<sn3gp690du7fg3laedicgslnn0sq6mpe4b@4ax.com>
In reply to#482
On Sat, 02 Apr 2011 17:30:17 -0400, Lew <noone@lewscanon.com> wrote,
quoted or indirectly quoted someone who said :

>Sure, it is an awful lot easier to do your homework once someone has given you 
>the answers.  We know.

I don't think these are his homework questions.  look up Luca on
google.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Doing what the user expects with respect to navigation is absurdly important for user satisfaction.
~ anonymous Google Android developer

[toc] | [prev] | [next] | [standalone]


#492

FromMerciadri Luca <Luca.Merciadri@student.ulg.ac.be>
Date2011-04-03 12:00 +0200
Message-ID<87pqp3bqon.fsf@merciadriluca-station.MERCIADRILUCA>
In reply to#482
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lew <noone@lewscanon.com> writes:

> Merciadri Luca wrote:
>> I'm given the following program snippet:
>>
>> ==
>> class C1
>> {
>>   public int n;
>> }
>>
>> interface I1
>> {
>>   int f();
>> }
>>
>> class C2 extends C1 implements I1
>> {
>>   public int f()
>>   {
>>    n = 18;
>>   }
>> }
>> ==
>> I need to say if the following expressions are valid or not
>> (justifications are trivial once I'm sure of the answer):
>
> Sure, it is an awful lot easier to do your homework once someone has
> given you the answers.  We know.

This is an extremely rude remark, especially when one does not know a
lot about somebody.

> But it seems rude that you ask for answers to your homework and
> haven't even tried to do the research yourself first.  Maybe somewhat
> more actionable than rude, even.

Same remark.
> Perhaps if you tell us first what you are thinking or trying, it will
> help counteract that unfortunate impression that you are trying to,
> ahem, cut corners.
>
>> 1. C1 obj_1 = new C2();
>> 2. C2 obj_2 = new C1();
>> 3. I1 obj_3 = new C2();
>> 4. I1 obj_4 = new I1();
>> 5. C2 obj_5 = new I1();
>>
>> I've found that 1. and 3. are valid, when the others (2., 4. and 5.)
>> are invalid. Am I right?
I told you what I thought valid and invalid. But you might have been
distracted during this moment. Anyway, 2., 4. and 5. are invalid, just
the way I guessed.

I was hesitating on these answers, but if my answers are right (and
they are, according to the compiler's output), I can justify them. So
there is no problem anymore. Closed thread.

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

Fine feathers make fine birds.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2YRSgACgkQM0LLzLt8MhyLDQCdGUXqG+M7UKaZtaDRrh5UEUf5
stgAn1M6pLquKH9FNgS4noeucY5KpjYO
=ASiw
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#483

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-04-02 20:53 -0700
Message-ID<forfp6995hk1thspo01mj5ccoggjb238ft@4ax.com>
In reply to#476
On Sat, 02 Apr 2011 22:13:26 +0200, Merciadri Luca
<Luca.Merciadri@student.ulg.ac.be> wrote, quoted or indirectly quoted
someone who said :

>I've found that 1. and 3. are valid, when the others (2., 4. and 5.)
>are invalid. Am I right?
 
If they compile, they are valid.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Doing what the user expects with respect to navigation is absurdly important for user satisfaction.
~ anonymous Google Android developer

[toc] | [prev] | [next] | [standalone]


#489

FromStanimir Stamenkov <s7an10@netscape.net>
Date2011-04-03 10:15 +0300
Message-ID<in96r7$7b9$1@dont-email.me>
In reply to#483
Sat, 02 Apr 2011 20:53:02 -0700, /Roedy Green/:
> On Sat, 02 Apr 2011 22:13:26 +0200, Merciadri Luca wrote:
>
>> I've found that 1. and 3. are valid, when the others (2., 4. and 5.)
>> are invalid. Am I right?
>
> If they compile, they are valid.

Unless one hits a compiler bug :-), like using Enum<?> declarations 
with the Diablo JDK (I've encountered recently).

-- 
Stanimir

[toc] | [prev] | [next] | [standalone]


#498

FromEric Sosman <esosman@ieee-dot-org.invalid>
Date2011-04-03 08:42 -0400
Message-ID<in9q0h$12p$1@dont-email.me>
In reply to#476
On 4/2/2011 4:13 PM, Merciadri Luca wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I'm given the following program snippet:
>
> ==
> class C1
> {
>   public int n;
> }
>
> interface I1
> {
>   int f();
> }
>
> class C2 extends C1 implements I1
> {
>   public int f()
>   {
>    n = 18;
>   }
> }
> ==
> I need to say if the following expressions are valid or not
> (justifications are trivial once I'm sure of the answer):
>
> 1. C1 obj_1 = new C2();

     Invalid.

> 2. C2 obj_2 = new C1();

     Invalid.

> 3. I1 obj_3 = new C2();

     Invalid.

> 4. I1 obj_4 = new I1();

     Invalid.

> 5. C2 obj_5 = new I1();

     Invalid.

> I've found that 1. and 3. are valid, when the others (2., 4. and 5.)
> are invalid. Am I right?

     No.

     Two suggestions, Merciadri.  First, while Usenet is a fine
channel for clearing up tricky questions or getting explanations
of confusing points, it is a poor vehicle for wholesale transfer
of large amounts of information.  Get a textbook or find a Web
site that devotes itself to teaching Java; these presentations
will organize the material in ways that make sense (if the writers
are good).  By posing a flood of random questions on Usenet you
take a random walk through the field of Java, and you will never
know whether you've covered all the ground or covered it adequately.

     Second, STOP posting paraphrases of the code you're asking
questions about!  Post the actual code, exactly what you gave to
the compiler, not a half-remembered half-accurate half-assed
approximation.  Case in point: Take the code you posted for this
very question, run it through the compiler, and see what the compiler
says about your five queries.  I predict you will get compile-time
errors for all five of them.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

[toc] | [prev] | [next] | [standalone]


#499

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-04-03 06:45 -0700
Message-ID<1ptgp6demkr2katcea6u8e5j063eu979c5@4ax.com>
In reply to#498
On Sun, 03 Apr 2011 08:42:23 -0400, Eric Sosman
<esosman@ieee-dot-org.invalid> wrote, quoted or indirectly quoted
someone who said :

>
>     Two suggestions, Merciadri.  First, while Usenet is a fine
>channel for clearing up tricky questions or getting explanations
>of confusing points, it is a poor vehicle for wholesale transfer
>of large amounts of information.  Get a textbook or find a Web
>site that devotes itself to teaching Java; these presentations
>will organize the material in ways that make sense (if the writers
>are good).  By posing a flood of random questions on Usenet you
>take a random walk through the field of Java, and you will never
>know whether you've covered all the ground or covered it adequately.

I suggest the same thing myself back a while.  See
http://mindprod.com/jgloss/gettingstarted.html

The text you need need not be up to date. You can get the latest and
greatest from tutorials and questions. This means you can get a
textbook very cheaply or free. You live in Belgium. I would send you
one myself if the cost of shipping were not higher than a new text.
Maybe someone nearby would be willing to donate one to you.

It is very common for people to try to con others into doing their
homework for them. see http://mindprod.com/jgloss/homework.html
They want the diploma without the knowledge. I don't know what they
expect to do once they get a job. You ask theoretical question rather
than ones you would encounter in the middle of a coding task. You also
offered multiple choice answers which further made it look as if you
were just parroting some course assignment. Somebody jerking us around
in order NOT to learn Java really burns Lew up, so he jumped to
conclusions.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Doing what the user expects with respect to navigation is absurdly important for user satisfaction.
~ anonymous Google Android developer

[toc] | [prev] | [next] | [standalone]


#501

FromMerciadri Luca <Luca.Merciadri@student.ulg.ac.be>
Date2011-04-03 17:29 +0200
Message-ID<874o6ffj5s.fsf@merciadriluca-station.MERCIADRILUCA>
In reply to#499
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Roedy Green <see_website@mindprod.com.invalid> writes:

> On Sun, 03 Apr 2011 08:42:23 -0400, Eric Sosman
> <esosman@ieee-dot-org.invalid> wrote, quoted or indirectly quoted
> someone who said :
>
>>
>>     Two suggestions, Merciadri.  First, while Usenet is a fine
>>channel for clearing up tricky questions or getting explanations
>>of confusing points, it is a poor vehicle for wholesale transfer
>>of large amounts of information.  Get a textbook or find a Web
>>site that devotes itself to teaching Java; these presentations
>>will organize the material in ways that make sense (if the writers
>>are good).  By posing a flood of random questions on Usenet you
>>take a random walk through the field of Java, and you will never
>>know whether you've covered all the ground or covered it adequately.
>
> I suggest the same thing myself back a while.  See
> http://mindprod.com/jgloss/gettingstarted.html
>
> The text you need need not be up to date. You can get the latest and
> greatest from tutorials and questions. This means you can get a
> textbook very cheaply or free. You live in Belgium. I would send you
> one myself if the cost of shipping were not higher than a new text.
> Maybe someone nearby would be willing to donate one to you.
>
> It is very common for people to try to con others into doing their
> homework for them. see http://mindprod.com/jgloss/homework.html
> They want the diploma without the knowledge. I don't know what they
> expect to do once they get a job. You ask theoretical question rather
> than ones you would encounter in the middle of a coding task. You also
> offered multiple choice answers which further made it look as if you
> were just parroting some course assignment. Somebody jerking us around
> in order NOT to learn Java really burns Lew up, so he jumped to
> conclusions.

But surely I'm not doing my homeworks! I can't understand this
remark. Do you really think I would be doing this when everybody could
see them by googling? These are not homeworks. These are mainlt
questions that were asked by the lecturer and for which I can't find
any answer using only his material. These questions do not give some
mark or anything. (If they did, I would not have posted so many things!!)

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

If you want breakfast in bed, sleep in the kitchen.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2Ykj8ACgkQM0LLzLt8MhyBsgCgrDwfoOcKeGP0oNNnoK389+g7
plUAn2084UBr4DWy0LcexUaTcB+kp+gW
=2Dyv
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#505

FromPatricia Shanahan <pats@acm.org>
Date2011-04-03 09:01 -0700
Message-ID<ENCdnRx8lbdeBAXQnZ2dnUVZ_qydnZ2d@earthlink.com>
In reply to#501
On 4/3/2011 8:29 AM, Merciadri Luca wrote:
...
> But surely I'm not doing my homeworks! I can't understand this
> remark. Do you really think I would be doing this when everybody could
> see them by googling? These are not homeworks. These are mainlt
> questions that were asked by the lecturer and for which I can't find
> any answer using only his material. These questions do not give some
> mark or anything. (If they did, I would not have posted so many things!!)

You may still be missing out on the intended benefit of the questions.
The lecturer may be deliberately asking you questions that require some
thought, experimentation, and reading beyond the handouts in order to
help you build the skills you would need to actually program in Java.

Patricia

[toc] | [prev] | [next] | [standalone]


#508

FromMerciadri Luca <Luca.Merciadri@student.ulg.ac.be>
Date2011-04-03 18:10 +0200
Message-ID<878vvruxhs.fsf@merciadriluca-station.MERCIADRILUCA>
In reply to#505
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Patricia Shanahan <pats@acm.org> writes:

> On 4/3/2011 8:29 AM, Merciadri Luca wrote:
> ...
>> But surely I'm not doing my homeworks! I can't understand this
>> remark. Do you really think I would be doing this when everybody could
>> see them by googling? These are not homeworks. These are mainlt
>> questions that were asked by the lecturer and for which I can't find
>> any answer using only his material. These questions do not give some
>> mark or anything. (If they did, I would not have posted so many things!!)
>
> You may still be missing out on the intended benefit of the questions.
> The lecturer may be deliberately asking you questions that require some
> thought, experimentation, and reading beyond the handouts in order to
> help you build the skills you would need to actually program in
> Java.

Sure, and that would be a great thing if these were not past exam
questions. This is an introductory course, and except the slides, and a
compiler, I don't have anything related to Java here. So it looks
easier to either look on the Internet or ask here if I can't find any
answer. The point is that such questions are never asked twice, but
they might help me learn some basic but underlying mechanisms of how
Java works.

There would certainly be a better way to learn them, e.g. by buying a
book which treats such subjects. But do you have any recommendation? I
am still looking for a book which would provide answers to such
questions by explaining thoroughly such specifities in a rather
theoretical way.

Generally, what I've read until there on the Internet does not explain
such things, and does not treat `picky' questions such as this one. If
I had a name of a book which would cover these subjects without
covering the rest from the very beginning, I would be glad reading
it. But as of now, I'm still confined to try inferences from
* my slides,
* my compiler,
* my JVM's output in the console.

Such inferences might be wrong, or simply unprecise or unadequate. As
a result, I generally like to confront my point of view (which might
be correct or simply too `creative' about some notions) to experts'
ones, and this is something I can do in an easier fashion on Usenet,
tolerating some rude and unjustified remarks from some experts in the
field. (You are obviously not in the `rude remarks' category, but some
here are and this is ... sad.)

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

In the land of the blind, the one-eyed man is king.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2Ym+8ACgkQM0LLzLt8Mhwp7QCeK/fhSFB4NzQK9m6dB6QLZfJ6
rOoAn3xKnUF0jso0+OxZELLkNCb3xHrE
=cmy6
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#510

FromPatricia Shanahan <pats@acm.org>
Date2011-04-03 09:32 -0700
Message-ID<CKqdnSidBq6gPAXQnZ2dnUVZ_v6dnZ2d@earthlink.com>
In reply to#508
On 4/3/2011 9:10 AM, Merciadri Luca wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Patricia Shanahan<pats@acm.org>  writes:
>
>> On 4/3/2011 8:29 AM, Merciadri Luca wrote:
>> ...
>>> But surely I'm not doing my homeworks! I can't understand this
>>> remark. Do you really think I would be doing this when everybody could
>>> see them by googling? These are not homeworks. These are mainlt
>>> questions that were asked by the lecturer and for which I can't find
>>> any answer using only his material. These questions do not give some
>>> mark or anything. (If they did, I would not have posted so many things!!)
>>
>> You may still be missing out on the intended benefit of the questions.
>> The lecturer may be deliberately asking you questions that require some
>> thought, experimentation, and reading beyond the handouts in order to
>> help you build the skills you would need to actually program in
>> Java.
>
> Sure, and that would be a great thing if these were not past exam
> questions. This is an introductory course, and except the slides, and a
> compiler, I don't have anything related to Java here. So it looks
> easier to either look on the Internet or ask here if I can't find any
> answer. The point is that such questions are never asked twice, but
> they might help me learn some basic but underlying mechanisms of how
> Java works.

If these are past exam questions, you really need to work on solving
them yourself. Knowing the answers to the old questions is useless.
Gaining the background knowledge, understanding, and skills needed to
answer the old questions is the best way I know to prepare to answer the
next set of exam questions.

> There would certainly be a better way to learn them, e.g. by buying a
> book which treats such subjects. But do you have any recommendation? I
> am still looking for a book which would provide answers to such
> questions by explaining thoroughly such specifities in a rather
> theoretical way.
>
> Generally, what I've read until there on the Internet does not explain
> such things, and does not treat `picky' questions such as this one. If
> I had a name of a book which would cover these subjects without
> covering the rest from the very beginning, I would be glad reading
> it. But as of now, I'm still confined to try inferences from
> * my slides,
> * my compiler,
> * my JVM's output in the console.

You have already been given several recommendations for reading matter.

All the questions you have posted could be answered by applying a good
basic general knowledge of Java to the question, rather than by already
knowing the answer. Indeed, I strongly suspect that the people who do
answer your questions are doing so by applying broad theory to the
specific "picky" question. There are just too many of those questions
for anyone to learn the answers to all of them.

For example, I had never previously thought about the harmful
consequences of writing a clone method by explicitly constructing a new
object. I did know to read the Object documentation for methods such as
clone that are defined in Object, and that it is important to think
through the implications of extending any non-final class.

> Such inferences might be wrong, or simply unprecise or unadequate. As
> a result, I generally like to confront my point of view (which might
> be correct or simply too `creative' about some notions) to experts'
> ones, and this is something I can do in an easier fashion on Usenet,
> tolerating some rude and unjustified remarks from some experts in the
> field. (You are obviously not in the `rude remarks' category, but some
> here are and this is ... sad.)

You might try a different sort of posting. Don't just post the question,
include your analysis. That way, we can see if you are thinking about
the question in a way that will also get the right answers to other
questions.

Patricia

[toc] | [prev] | [next] | [standalone]


#511

FromMerciadri Luca <Luca.Merciadri@student.ulg.ac.be>
Date2011-04-03 18:48 +0200
Message-ID<874o6f46x5.fsf@merciadriluca-station.MERCIADRILUCA>
In reply to#510
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Patricia Shanahan <pats@acm.org> writes:

> On 4/3/2011 9:10 AM, Merciadri Luca wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Patricia Shanahan<pats@acm.org>  writes:
>>
>>> On 4/3/2011 8:29 AM, Merciadri Luca wrote:
>>> ...
>>>> But surely I'm not doing my homeworks! I can't understand this
>>>> remark. Do you really think I would be doing this when everybody could
>>>> see them by googling? These are not homeworks. These are mainlt
>>>> questions that were asked by the lecturer and for which I can't find
>>>> any answer using only his material. These questions do not give some
>>>> mark or anything. (If they did, I would not have posted so many things!!)
>>>
>>> You may still be missing out on the intended benefit of the questions.
>>> The lecturer may be deliberately asking you questions that require some
>>> thought, experimentation, and reading beyond the handouts in order to
>>> help you build the skills you would need to actually program in
>>> Java.
>>
>> Sure, and that would be a great thing if these were not past exam
>> questions. This is an introductory course, and except the slides, and a
>> compiler, I don't have anything related to Java here. So it looks
>> easier to either look on the Internet or ask here if I can't find any
>> answer. The point is that such questions are never asked twice, but
>> they might help me learn some basic but underlying mechanisms of how
>> Java works.
>
> If these are past exam questions, you really need to work on solving
> them yourself. Knowing the answers to the old questions is useless.
> Gaining the background knowledge, understanding, and skills needed to
> answer the old questions is the best way I know to prepare to answer the
> next set of exam questions.

I agree totally on this point. But there is sometimes such a gap
between a theoretic course and what you should be able to do for it!
But I'll try, anyway. I generally adopt this approach for most of the
courses, but to begin in a special field, I like to learn from others'
(in this case experts') answers. But there is no problem anyway.

>> There would certainly be a better way to learn them, e.g. by buying a
>> book which treats such subjects. But do you have any recommendation? I
>> am still looking for a book which would provide answers to such
>> questions by explaining thoroughly such specifities in a rather
>> theoretical way.
>>
>> Generally, what I've read until there on the Internet does not explain
>> such things, and does not treat `picky' questions such as this one. If
>> I had a name of a book which would cover these subjects without
>> covering the rest from the very beginning, I would be glad reading
>> it. But as of now, I'm still confined to try inferences from
>> * my slides,
>> * my compiler,
>> * my JVM's output in the console.
>
> You have already been given several recommendations for reading matter.
>
> All the questions you have posted could be answered by applying a good
> basic general knowledge of Java to the question, rather than by already
> knowing the answer. Indeed, I strongly suspect that the people who do
> answer your questions are doing so by applying broad theory to the
> specific "picky" question. There are just too many of those questions
> for anyone to learn the answers to all of them.

Yes, I suspect this too. This is totally incumbent on a way of
reasoning, etc., but the problem is that it takes time to acquire such
a reasoning. And I sometimes want to skip some steps, which might not
be a good idea.

> For example, I had never previously thought about the harmful
> consequences of writing a clone method by explicitly constructing a new
> object. I did know to read the Object documentation for methods such as
> clone that are defined in Object, and that it is important to think
> through the implications of extending any non-final class.
>
>> Such inferences might be wrong, or simply unprecise or unadequate. As
>> a result, I generally like to confront my point of view (which might
>> be correct or simply too `creative' about some notions) to experts'
>> ones, and this is something I can do in an easier fashion on Usenet,
>> tolerating some rude and unjustified remarks from some experts in the
>> field. (You are obviously not in the `rude remarks' category, but some
>> here are and this is ... sad.)
>
> You might try a different sort of posting. Don't just post the question,
> include your analysis. That way, we can see if you are thinking about
> the question in a way that will also get the right answers to other
> questions.

This is what I did in some messages, but effectively not in all. I'll
try to be more explicit now. Thanks for the interesting answers.

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

It is better to die on one's feet than live on one's knees.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2YpPYACgkQM0LLzLt8MhyHogCdEnJccblRDJYad/x5gRZ2wxyY
9aAAoIuEWN6B4QqP0o47vyMtA060lfUv
=FerD
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#507

FromAéris <aeris@imirhil.fr>
Date2011-04-03 18:07 +0200
Message-ID<4d989b27$0$21177$426a34cc@news.free.fr>
In reply to#501
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le 03/04/2011 17:29, Merciadri Luca a écrit :
> These are mainlt
> questions that were asked by the lecturer and for which I can't find
> any answer using only his material.

Sorry, but in this case, given the very low level of most of your
questions :
— Have you ever read any Java tutorial or documentation ?
— What the hell ? You made Java lecture with this skill level ? Uh…

For example, this question about class/subclass/interface/cast is
learned in the first Java lesson in any of French computing school, even
if this is not in the first lesson !
And any Java begginer tutorial deals with it in the early chapters.

And with 30s more, you will be able to try to compile your examples and
have your response immediatly.

- -- 
Aeris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNmJshAAoJEK8zQvxDY4P9HIcH/0joE0UTDx57q7R0gLWCn7bE
baAclzKAD+07ynT4WVssz8NhdbCkO/ud7Drn4P2BWgF4ImeIIkbF0udRHVaCLeKO
Hkn3YlIwat4BOQBnzX/73Hnib9IA97qTM14fywdqTDbhk+PlPwZN9qc94iRIhG3N
FnryXZzZ/1hiqlinXQesJAU8COx4fvc/UvJIvtbfJY/2vohnZtAAh6sr9forWyw3
8XUYvUoUVgf/8ds1QyZaVEDiOUppY7bDBwn3+hLio6GsLVegS0b3VL63hnqqSH6R
M6klisnffqOcKpHSYwmlrEwyo3bi9VBdVu3XhyUJGq367zsHBniqekqB/LyA2OI=
=cxAl
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#509

FromMerciadri Luca <Luca.Merciadri@student.ulg.ac.be>
Date2011-04-03 18:22 +0200
Message-ID<87lizr1f02.fsf@merciadriluca-station.MERCIADRILUCA>
In reply to#507
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aéris <aeris@imirhil.fr> writes:

> Le 03/04/2011 17:29, Merciadri Luca a écrit :
>> These are mainlt
>> questions that were asked by the lecturer and for which I can't find
>> any answer using only his material.
>
> Sorry, but in this case, given the very low level of most of your
> questions :
> — Have you ever read any Java tutorial or documentation ?

Not that much. See my preceding message.
> — What the hell ? You made Java lecture with this skill level ? Uh…

I am attending to a course which treates about the object-oriented
approach. Its role is not at all to make the students learn Java. Java
is just some (good) `excuse' to practice OO programming.

But, as a result, I lack practice in this language, even if I had some
project to do that I did in not more than some days. I'm lacking long
term practice.

You need to understand that, at our universities, we do not have
courses about some specific language, as it is mostly done in what is
here commonly referred to as `superior schools.' I won't make you
learn anything by teling you that it is better to learn some way of
reasoning than to learn some language syntax. But language syntax is
obviously necessary for implementing theoretical questions, and
algorithms. But one needs here to understand that this is not at all
the primary goal of the course.

> For example, this question about class/subclass/interface/cast is
> learned in the first Java lesson in any of French computing school, even
> if this is not in the first lesson !
I'm not that aware of the French schools, but I know they are very
specialized in specific domains where they mostly form experts in a
specific domain. This is generally not the case here in Belgium. (But
you might correct me if necessary.)

> And any Java begginer tutorial deals with it in the early chapters.
>
> And with 30s more, you will be able to try to compile your examples and
> have your response immediatly.

What some people here do not understand is that having an answer such
as `well, instruction X or Y is invalid' is utterly uninteresting to
me, because
1) I want to know why,
2) the compiler can already give me the answers about which
instructions are valid or not. In some cases, the compiler message
might even explain why.

Take a look at my first message. I mentioned which instructions I
expected to be valid, and the ones I expected to be invalid. People
directly answer that my question is about some homework, etc., or they
mention that I need to compile them to be sure about which ones are
valid and which ones are not. But I know that the compiler can tell me
which ones are valid and which ones are not!

The `Am I right?' question of the message 1 had to be read as `How
could you justify this?', which is now a question for which I've found
the answers by myself.

As a result, this discussion contained a lot of unuseful messages
about uninteresting remarks for some people. The answer I wanted was a
justification. But I found it myself, so this was a total lack of time
and a total gain of frustration regarding some people who seem to
understand nothing about this. But that's not a problem.

All the best,

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

Give a man a fish and you feed him for a day; teach a man to fish
  and you feed him for a lifetime.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2Yns0ACgkQM0LLzLt8MhxuogCfVxUnZuFHB80tRhx9sfo3bZKl
RasAn0SMZ6nrn1Q4POzCHslJo1u1563m
=76Rk
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#512

FromAéris <aeris@imirhil.fr>
Date2011-04-03 19:02 +0200
Message-ID<4d98a82d$0$23733$426a74cc@news.free.fr>
In reply to#509
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le 03/04/2011 18:22, Merciadri Luca a écrit :
> I am attending to a course which treates about the object-oriented
> approach. Its role is not at all to make the students learn Java. Java
> is just some (good) `excuse' to practice OO programming.

Even if I made Java abstraction, all your question is OOP only, and at a
very beginning level skill.

Difference between « identity » (==) or « equality » (.equals),
subclass/interface casting and assigment, overridding, constructor
inheritance…
All those points are NECESSARY to do any OOP (Java, C++, C# or any other
OO languages), so I question myself why you assist to lecture about «
advanced » OOP patterns without those prerequisites or why your lecturer
doesn't learn you those points, before seeing advanced points.

> But, as a result, I lack practice in this language, even if I had some
> project to do that I did in not more than some days. I'm lacking long
> term practice.

For me, your question is not at all Java oriented the most of the time.
If you lack practice, this is in OOP overall, and not only in Java
specially.

- -- 
Aeris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNmKgoAAoJEK8zQvxDY4P9kSwH/i+YFxNE3qJPCv1N0lf+mIto
FJ7njoOIW+Vlojf+fRawrYDwBdOLRcDPkAAIUTZwtr8gfSUt+W8OoJX6nbRjm55Y
Jy9Dmq7CyOOA/07TysTqnObhivX0NSs/RnlemghFACbuC9dLBrC4a08VxG5v+mJz
f7rvZHGqrhIvuWJ0mEYhXtc1HkNDYRqfq9bU22054IGPxtudFVv6G1srNMwudF3F
zvuLBD9oJdesiAzCIblWXl4yJ4bQbYVC+o9GX+GIl71DgQOcIG/4HtDvyGoRR59O
fVx0Uw2lPgcHG8bGbCq/nxBXAXdXHQAEGV8s3BMnjc5oQXki+p0XmWjS5gUT+EE=
=Sc6r
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#516

FromMerciadri Luca <Luca.Merciadri@student.ulg.ac.be>
Date2011-04-03 20:15 +0200
Message-ID<87fwpzjj59.fsf@merciadriluca-station.MERCIADRILUCA>
In reply to#512
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aéris <aeris@imirhil.fr> writes:

> Le 03/04/2011 18:22, Merciadri Luca a écrit :
>> I am attending to a course which treates about the object-oriented
>> approach. Its role is not at all to make the students learn Java. Java
>> is just some (good) `excuse' to practice OO programming.
>
> Even if I made Java abstraction, all your question is OOP only, and at a
> very beginning level skill.
>
> Difference between « identity » (==) or « equality » (.equals),
> subclass/interface casting and assigment, overridding, constructor
> inheritance…
> All those points are NECESSARY to do any OOP (Java, C++, C# or any other
> OO languages), so I question myself why you assist to lecture about «
> advanced » OOP patterns without those prerequisites or why your lecturer
> doesn't learn you those points, before seeing advanced points.
But I totally agree with you. I don't remember if I used the word
`advanced' in some message, but if so, I used it inappropriately, as this is an
*introductory* course in OOP. The problem is that the concepts are
introduced one after another, and there are still some concepts I
haven't seen yet, but that I obviously need to understand before doing
such exercises.

>> But, as a result, I lack practice in this language, even if I had some
>> project to do that I did in not more than some days. I'm lacking long
>> term practice.
>
> For me, your question is not at all Java oriented the most of the time.
> If you lack practice, this is in OOP overall, and not only in Java
> specially.
Okay. Well, I need to practice OOP, then.

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

If it's too good to be true, then it probably is.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2YuVEACgkQM0LLzLt8MhxEJQCgosxHUQE01ej86MwSFMDQr4pc
awEAn0XNAM9NSyTfd8E88USsp9uocIEp
=Kr0H
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#547

FromLew <noone@lewscanon.com>
Date2011-04-06 12:01 -0400
Message-ID<ini2o7$30t$1@news.albasani.net>
In reply to#499
On 04/03/2011 09:45 AM, Roedy Green wrote:
> It is very common for people to try to con others into doing their
> homework for them. see http://mindprod.com/jgloss/homework.html
> They want the diploma without the knowledge. I don't know what they
> expect to do once they get a job. You ask theoretical question rather
> than ones you would encounter in the middle of a coding task. You also
> offered multiple choice answers which further made it look as if you
> were just parroting some course assignment. Somebody jerking us around
> in order NOT to learn Java really burns Lew up, so he jumped to
> conclusions.

It wasn't a leap, it was a tiptoe.  Merciadri never answers our questions, he 
demands a full Java education without making any effort himself, he 
condescendingly says, "thread closed" instead of interacting, he puts forward 
questions that read exactly like textbook exercises, he consistently rejects 
our advice, when he announces a "solution" he never tells us what it is, and 
when I call him on it he calls *me* rude.

Qu'il est cochon.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#500

FromMerciadri Luca <Luca.Merciadri@student.ulg.ac.be>
Date2011-04-03 17:27 +0200
Message-ID<878vvrfj81.fsf@merciadriluca-station.MERCIADRILUCA>
In reply to#498
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eric Sosman <esosman@ieee-dot-org.invalid> writes:

> On 4/2/2011 4:13 PM, Merciadri Luca wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi,
>>
>> I'm given the following program snippet:
>>
>> ==
>> class C1
>> {
>>   public int n;
>> }
>>
>> interface I1
>> {
>>   int f();
>> }
>>
>> class C2 extends C1 implements I1
>> {
>>   public int f()
>>   {
>>    n = 18;
>>   }
>> }
>> ==
>> I need to say if the following expressions are valid or not
>> (justifications are trivial once I'm sure of the answer):
>>
>> 1. C1 obj_1 = new C2();
>
>     Invalid.
>
>> 2. C2 obj_2 = new C1();
>
>     Invalid.
>
>> 3. I1 obj_3 = new C2();
>
>     Invalid.
>
>> 4. I1 obj_4 = new I1();
>
>     Invalid.
>
>> 5. C2 obj_5 = new I1();
>
>     Invalid.
>
>> I've found that 1. and 3. are valid, when the others (2., 4. and 5.)
>> are invalid. Am I right?
>
>     No.
>
>     Two suggestions, Merciadri.  First, while Usenet is a fine
> channel for clearing up tricky questions or getting explanations
> of confusing points, it is a poor vehicle for wholesale transfer
> of large amounts of information.  Get a textbook or find a Web
> site that devotes itself to teaching Java; these presentations
> will organize the material in ways that make sense (if the writers
> are good).  By posing a flood of random questions on Usenet you
> take a random walk through the field of Java, and you will never
> know whether you've covered all the ground or covered it adequately.
>
>     Second, STOP posting paraphrases of the code you're asking
> questions about!  Post the actual code, exactly what you gave to
> the compiler, not a half-remembered half-accurate half-assed
> approximation.  Case in point: Take the code you posted for this
> very question, run it through the compiler, and see what the compiler
> says about your five queries.  I predict you will get compile-time
> errors for all five of them.

Thanks for the tips. I'll try to get a textbook. The problem is that
I'm learning Java for some course and that I don't have a sufficient
amount of (academic) time to learn Java in depth. So I'll try to do my best.

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

If all else fails, try the obvious.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2Yke4ACgkQM0LLzLt8MhyeKgCfUCban+2lDyf4FeGP6j+Coo/9
h3YAn08fHn9EXw6+J4aK7rP7W8OW7d3a
=bGdn
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#517

FromEric Sosman <esosman@ieee-dot-org.invalid>
Date2011-04-03 14:26 -0400
Message-ID<inae6c$k3c$1@dont-email.me>
In reply to#500
On 4/3/2011 11:27 AM, Merciadri Luca wrote:
> [...]
> Thanks for the tips. I'll try to get a textbook. The problem is that
> I'm learning Java for some course and that I don't have a sufficient
> amount of (academic) time to learn Java in depth. So I'll try to do my best.

     If your "best" consists of firing random questions at Usenet and
engaging in long discussions about the answers, you will make very
slow progress.  Indeed, it will take you more time than reading a
textbook, and will benefit you less.

     Also, if you don't have time to learn Java "in depth," just how
shallowly do you intend to learn it?  And why should anyone here waste
time helping you with your shallowness?  I for one am not interested
in spending my own time helping somebody avoid learning.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.java.help


csiph-web