This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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 Elasticsearch in Action this week in the Big Data 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: 19908

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