Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-05-2008, 03:33 PM
Member
 
Join Date: Nov 2007
Posts: 35
java_fun2007 is on a distinguished road
hiding inherited methods
hi,
I need to know how to hide a method from a subclass because it doesn't need it at all. I think using aggregation will solve the problem but how? do you have any examples regarding this please?

For example, if the class Dog defines the properties "bark," "fetch," and "eat food" then a class Cat can be derived from Dog by hiding "bark" and "fetch" and adding "purr" and "sleep." And then "bark" shouldn't appear in the Cat class, is using aggregation solve the problem? by putting the class Cat as "whole" and class Dog as its "part".
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-05-2008, 04:16 PM
Senior Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 102
wsaryada is on a distinguished road
First I think Cat should never derived from Dog, as just in a real world Cat and Dog are different species. You could create an Animal class which then can be derived by both Cat and Dog.

If you correctly define your method you should not have to do method hiding this way. In Java the access modifier such as public, protected, the default and private can be choose whether the method or field can be inherited to the child class.
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding parameters from URL Saurabh321 New To Java 0 02-05-2008 02:43 PM
abstract extended and hiding variable?? Ace_Of_John New To Java 5 12-23-2007 04:46 PM
Hiding the frame’s title bar Java Tip Java Tips 0 12-21-2007 10:41 AM
Top menu fields hiding youayshu JavaServer Pages (JSP) and JSTL 0 11-13-2007 09:10 AM
Hiding a method or function using PHP file Raj Singh Eclipse 1 08-09-2007 09:26 PM


All times are GMT +3. The time now is 01:20 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org