Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1856 > unrolled thread
| Started by | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| First post | 2012-06-13 13:21 -0700 |
| Last post | 2012-06-14 12:43 -0700 |
| Articles | 12 — 6 participants |
Back to article view | Back to comp.lang.java.help
Brain teaser for newbies Roedy Green <see_website@mindprod.com.invalid> - 2012-06-13 13:21 -0700
Re: Brain teaser for newbies Lew <lewbloch@gmail.com> - 2012-06-13 14:15 -0700
Re: Brain teaser for newbies Roedy Green <see_website@mindprod.com.invalid> - 2012-06-13 20:46 -0700
Re: Brain teaser for newbies Lew <noone@lewscanon.com> - 2012-06-13 22:43 -0700
Re: Brain teaser for newbies Roedy Green <see_website@mindprod.com.invalid> - 2012-06-14 11:06 -0700
Re: Brain teaser for newbies markspace <-@.> - 2012-06-14 11:45 -0700
Re: Brain teaser for newbies Roedy Green <see_website@mindprod.com.invalid> - 2012-06-14 11:14 -0700
Re: Brain teaser for newbies Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-14 12:17 -0700
Re: Brain teaser for newbies Roedy Green <see_website@mindprod.com.invalid> - 2012-06-14 21:11 -0700
Re: Brain teaser for newbies Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2012-06-15 08:14 +0300
Re: Brain teaser for newbies Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-15 11:08 -0700
Re: Brain teaser for newbies Lew <lewbloch@gmail.com> - 2012-06-14 12:43 -0700
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-06-13 13:21 -0700 |
| Subject | Brain teaser for newbies |
| Message-ID | <c1tht7h7d9ur58ul0jovl34l3ar4bgfajb@4ax.com> |
Write a compilable running java class that contains both an abstract method and a main method. -- Roedy Green Canadian Mind Products http://mindprod.com Controlling complexity is the essence of computer programming. ~ Brian W. Kernighan 1942-01-01 .
[toc] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-06-13 14:15 -0700 |
| Message-ID | <95c091d5-59c5-4b1f-9b67-8b9ee8208954@googlegroups.com> |
| In reply to | #1856 |
On Wednesday, June 13, 2012 1:21:35 PM UTC-7, Roedy Green wrote: > Write a compilable running java class that contains both an abstract > method and a main method. "compilable running"? Doesn't "running" imply "compilable"? -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-06-13 20:46 -0700 |
| Message-ID | <4init7toalcrdb6kbdqmma8dfjc5lh4kaf@4ax.com> |
| In reply to | #1857 |
On Wed, 13 Jun 2012 14:15:48 -0700 (PDT), Lew <lewbloch@gmail.com> wrote, quoted or indirectly quoted someone who said : > >Doesn't "running" imply "compilable"? For a newbie yes, but you can construct class files without writing Java code. -- Roedy Green Canadian Mind Products http://mindprod.com Controlling complexity is the essence of computer programming. ~ Brian W. Kernighan 1942-01-01 .
[toc] | [prev] | [next] | [standalone]
| From | Lew <noone@lewscanon.com> |
|---|---|
| Date | 2012-06-13 22:43 -0700 |
| Message-ID | <jrbtm6$6so$1@news.albasani.net> |
| In reply to | #1859 |
Roedy Green wrote: > Lew wrote, quoted or indirectly quoted someone who said : >> >> Doesn't "running" imply "compilable"? > > For a newbie yes, but you can construct class files without writing > Java code. That is an excellent and subtle point. Thank you. > Write a compilable running [J]ava class that contains both an abstract > method and a main method. A very interesting puzzle. I truly am enjoying it. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-06-14 11:06 -0700 |
| Message-ID | <ds9kt71qp56ti5v84d8o6u43cvfngjs5jr@4ax.com> |
| In reply to | #1860 |
On Wed, 13 Jun 2012 22:43:36 -0700, Lew <noone@lewscanon.com> wrote, quoted or indirectly quoted someone who said : > >A very interesting puzzle. I truly am enjoying it. I can think of two basic ways of doing it. One you might discount on the grounds you would quibble on the meaning of "class". -- Roedy Green Canadian Mind Products http://mindprod.com Controlling complexity is the essence of computer programming. ~ Brian W. Kernighan 1942-01-01 .
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-06-14 11:45 -0700 |
| Message-ID | <jrdbfm$nrb$1@dont-email.me> |
| In reply to | #1865 |
On 6/14/2012 11:06 AM, Roedy Green wrote: > On Wed, 13 Jun 2012 22:43:36 -0700, Lew<noone@lewscanon.com> wrote, > quoted or indirectly quoted someone who said : > >> >> A very interesting puzzle. I truly am enjoying it. > > I can think of two basic ways of doing it. One you might discount on > the grounds you would quibble on the meaning of "class". I can think of two ways, one of which has three somewhat minor variations, and the other is basically a cheat and has two variations. The cheater depends on your definition of "contains."
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-06-14 11:14 -0700 |
| Message-ID | <t8akt7du9pfedg44r8r96mv8bijpib7cgb@4ax.com> |
| In reply to | #1860 |
On Wed, 13 Jun 2012 22:43:36 -0700, Lew <noone@lewscanon.com> wrote, quoted or indirectly quoted someone who said : >A very interesting puzzle. I truly am enjoying it. Professor Melzak (who taught discrete math at UBC) once told us a what he claimed was a true story. A prof was writing a proof on the blackboard (a green, erasable vertical surface on which one wrote with a stick of chalk). A student stuck up his hand and said, "I don't see how you got from step 10 to 11". The prof said "It's trivial". The student said, "I still don't see it." The prof stared at it, and stared. 15 minutes went by. He left the room. Just as the class was about to dismiss, he returned and said "It IS trivial". -- Roedy Green Canadian Mind Products http://mindprod.com Controlling complexity is the essence of computer programming. ~ Brian W. Kernighan 1942-01-01 .
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-14 12:17 -0700 |
| Message-ID | <_MqCr.14183$GJ4.50@newsfe16.iad> |
| In reply to | #1866 |
On 6/14/12 11:14 AM, Roedy Green wrote: > On Wed, 13 Jun 2012 22:43:36 -0700, Lew<noone@lewscanon.com> wrote, > quoted or indirectly quoted someone who said : > >> A very interesting puzzle. I truly am enjoying it. > > Professor Melzak (who taught discrete math at UBC) once told us a what > he claimed was a true story. > > A prof was writing a proof on the blackboard (a green, erasable > vertical surface on which one wrote with a stick of chalk). > > A student stuck up his hand and said, "I don't see how you got from > step 10 to 11". > > The prof said "It's trivial". > > The student said, "I still don't see it." > > The prof stared at it, and stared. 15 minutes went by. He left the > room. Just as the class was about to dismiss, he returned and said > "It IS trivial". > Unless I'm missing something, this puzzle is trivial. Perhaps I have confusion over what "running java class" really means? Do you mean a class you can start with the "java" command?
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-06-14 21:11 -0700 |
| Message-ID | <pedlt71nvmbfirikd07eb9fckdulm0baid@4ax.com> |
| In reply to | #1868 |
On Thu, 14 Jun 2012 12:17:12 -0700, Daniel Pitts <newsgroup.nospam@virtualinfinity.net> wrote, quoted or indirectly quoted someone who said : >Perhaps I have confusion over what "running java class" really means? Do >you mean a class you can start with the "java" command? yes. I intended this a puzzle for newbies. -- Roedy Green Canadian Mind Products http://mindprod.com Controlling complexity is the essence of computer programming. ~ Brian W. Kernighan 1942-01-01 .
[toc] | [prev] | [next] | [standalone]
| From | Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> |
|---|---|
| Date | 2012-06-15 08:14 +0300 |
| Message-ID | <m3haudkvgs.fsf@ipa.eternal-september.org> |
| In reply to | #1870 |
Roedy Green <see_website@mindprod.com.invalid> writes: > On Thu, 14 Jun 2012 12:17:12 -0700, Daniel Pitts >>Perhaps I have confusion over what "running java class" really means? Do >>you mean a class you can start with the "java" command? > yes. I intended this a puzzle for newbies. Hmm, doesn't seem to be much of a puzzle. There's nothing to stop having a main method and an abstract method in the same class. But when I tested this with a simple class, I was surprised to see that not only did it compile ok, but the jvm didn't even complain about invoking an abstract class called Test with "java Test". Now that I thnk about it, it was because I didn't actually try to instantiate it, the only thing in my main method was a simple System.out.println call to show that it was executed. And the next test confirmed this: when I added "Test inst = new Test()", the compiler showed the expected error message "Test is abstract; cannot be instantiated". -- Jukka Lahtinen
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-15 11:08 -0700 |
| Message-ID | <9SKCr.2570$7y4.880@newsfe23.iad> |
| In reply to | #1871 |
On 6/14/12 10:14 PM, Jukka Lahtinen wrote: > Roedy Green<see_website@mindprod.com.invalid> writes: >> On Thu, 14 Jun 2012 12:17:12 -0700, Daniel Pitts > >>> Perhaps I have confusion over what "running java class" really means? Do >>> you mean a class you can start with the "java" command? > >> yes. I intended this a puzzle for newbies. > > Hmm, doesn't seem to be much of a puzzle. [snip] It is customary to indicate *SPOILER* before giving the solution to a problem such as this.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-06-14 12:43 -0700 |
| Message-ID | <4e12e06d-e4ab-4ce0-9779-78fb4f514e0a@googlegroups.com> |
| In reply to | #1866 |
Roedy Green wrote: > Professor Melzak (who taught discrete math at UBC) once told us a what > he claimed was a true story. > > A prof was writing a proof on the blackboard (a green, erasable > vertical surface on which one wrote with a stick of chalk). > > A student stuck up his hand and said, "I don't see how you got from > step 10 to 11". > > The prof said "It's trivial". > > The student said, "I still don't see it." > > The prof stared at it, and stared. 15 minutes went by. He left the > room. Just as the class was about to dismiss, he returned and said > "It IS trivial". Every version of that story I've heard over the years was averred to be a true story. -- Lew
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.help
csiph-web