Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #498
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: Class ... implements ... |
| Date | 2011-04-03 08:42 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <in9q0h$12p$1@dont-email.me> (permalink) |
| References | <87vcywpg2h.fsf@merciadriluca-station.MERCIADRILUCA> |
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
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web