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


Groups > comp.lang.java.help > #1871

Re: Brain teaser for newbies

From Jukka Lahtinen <jtfjdehf@hotmail.com.invalid>
Newsgroups comp.lang.java.help
Subject Re: Brain teaser for newbies
Date 2012-06-15 08:14 +0300
Organization A noiseless patient Spider
Message-ID <m3haudkvgs.fsf@ipa.eternal-september.org> (permalink)
References (2 earlier) <4init7toalcrdb6kbdqmma8dfjc5lh4kaf@4ax.com> <jrbtm6$6so$1@news.albasani.net> <t8akt7du9pfedg44r8r96mv8bijpib7cgb@4ax.com> <_MqCr.14183$GJ4.50@newsfe16.iad> <pedlt71nvmbfirikd07eb9fckdulm0baid@4ax.com>

Show all headers | View raw


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

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web