in response to Jan...

but how would u still stop the an instance of the child class 
Sub from calling the inherited m1() method?

i am not sure the original question is a valid one in the first place?  how is 
it possible that a method declared public/protected by a parent class be NOT 
accessible by child class?

this would throw the entire concept of inheritance out of the window?

Anil, are you sure u have got ur requirements correctly mapped?

best,
-Piyush

_________________________Reply Separator_________________________

Jan Materne wrote:

OK: you want to have methods in a (super)class which can be 
accessed by "normal" classes but can't by subclasses? 

As far as I know, there is no (direct) way. But you can use 
"delegation" for it: 

public interface CommonMethods { 
  public int m1(int a); 
} 

public class CommonMethodsImpl implements CommonMethods { 
  public int m1(int a) { 
    // Implementation goes here 
    return a; 
  } 
} 

public class Super implements CommonMethods { 
  // for delegation 
  private CommonMethods cm = new CommonMethodsImpl(); 

  // the delegation 
  public int m1(int a) { 
    return cm.m1(a); 
  } 
} 

public class Sub extends CommonMethods { 
  // normal implementation 
} 

************************************************************************
* Rose Forum is a public venue for ideas and discussions.
* For technical support, visit http://www.rational.com/support
*
* Post or Reply to: [EMAIL PROTECTED]
* Subscription Requests: [EMAIL PROTECTED]
* Archive of messages:
*    http://www.rational.com/support/usergroups/rose/rose_forum.jsp
* Other Requests: [EMAIL PROTECTED]
*
* To unsubscribe from the list, please send email
*    To: [EMAIL PROTECTED]
*    Subject: <BLANK>
*    Body: unsubscribe rose_forum
*************************************************************************

Reply via email to