Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 10:12 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: why cant instantiate an abstract class
PostPosted: Wed Oct 22, 2008 12:46 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

My question is why java has put the restriction that you can not
instantiate an abstract class, I know that abstract classes are meant to be
extended but we can think this way that lets say a class has three methods,
out of which one is abstract.

Now it would not be better that java allows to create the object of that
class so that we can use the functionality of the two non-abstract methods
and if some one tries to use an abstract method then run time exception or
any thing else could be done.

So why java chose to put restriction on instantiation of abstract class
??????


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: why cant instantiate an abstract class
PostPosted: Wed Oct 22, 2008 12:47 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:53 pm
Posts: 229
Has thanked: 0 time
Have thanks: 0 time
Abstract classes not only choose not to implement specific methods, but
typically these abstract methods are used by the concrete methods. This
way a programmer can code the program flow in a concrete method while
leaving the details of how it works to a subclass.

For an example, take a look at the Collections framework. Sun provided
abstract base classes for most interfaces such as List and Map. These
classes can implement some methods fully, and some are abstract. Some of
the concrete methods in abstract classes call into abstract methods, and
such method calls would fail.

In any event, does it make any sense to instantiate an AbstractList? By
definition, it is not complete and cannot provide a full implementation
of the List interface.


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 Issues with class, need help
 C C++ program help using class
 Not to find nativeEncoder class jar
 PHP class example
 concrete class
 Having a hard time with this class need help deseperately.
 Ladies & Gents Watches for 150-450 AED ,High Class.
 Set up Class Path For Java
 abstract factory implementation .please help me?
 Persisting a class into two tables

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 3 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team