aspose file tools*
The moose likes Beginning Java and the fly likes Restriction on parent class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Restriction on parent class" Watch "Restriction on parent class" New topic
Author

Restriction on parent class

faisal hameed
Ranch Hand

Joined: Jan 19, 2009
Posts: 48
//can we apply restriction on parent class that he cannot creat object of shape type


Regards, M Faisal Hameed
PUCIT, Pakistan
Rakesh Enoch
Greenhorn

Joined: Jun 27, 2008
Posts: 23
Make Shape an Interface. Let other classes implement it. This way you cannot intantiate Shape Class.


Rakesh Enoch SCJP 1.5 86%
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19794
    
  20

And if you can't make it an interface, make it abstract. An abstract class does not need to have any abstract methods, so all you need to do is add the abstract modifier to the class.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Restriction on parent class