File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Restriction on parent class" Watch "Restriction on parent class" New topic

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

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

Joined: Oct 27, 2005
Posts: 19543

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Restriction on parent class
Similar Threads
static overloaded methods
Whizlabs test question : Generics
Generics: Shape example does not work as SUN says
Generics Casting
Are my classes shaped correctly?