• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is the main resaon for con't create object for abstract class

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Frndz,

I am new to java .I have a doubt on Abstract class


Thanks in advance
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not "Frndz", please.

That is how it is defined. That is the meaning of "abstract".
The reason you can't create an object of an abstract class is that an abstract class is defined as one you can't create an object of.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Abstract classes may have abstract methods - methods without an implementation. What should the JVM do if you try to call such a method?
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

we cant use abstract class for creating objects ..because abstract class has atleast one or more abstract methods(method without definition )
but you can extend the abstract class by defining all the abstract methods in that and create the object by using the sub class..
one main thing in this is when you miss to define one or more abstract method ..your sub class also must be an abstract class..


 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

saravanan ragunathan wrote:because abstract class has atleast one or more abstract methods(method without definition )


No it doesn't. The following is perfectly legal:
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

saravanan ragunathan wrote:. . .because abstract class has atleast one or more abstract methods(method without definition ) . . .

As Rob has already said, that is not quote correct. The reason is that "abstract" means untouchable and not solid, so it is used in Java™ to mean "don't create any objects of this class".

You can actually create instances of an abstract class as an anonymous class, but that is a different story.
 
I do some of my very best work in water. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic