title: Java abstraction and interface
body: <p>I am looking for a solution to a problem in Java. Hope team can help me.</p>
  
  <p>Consider following classes:</p>
  
  <pre><code>Class A{
  //constructor
  Object obj;
  
  public A(Object obj){
   this.obj = obj;
  }
  
  public void ma1(){
        system.out.println("In ma1");
        obj.mc1();
  }
  
  public void ma2(){
        system.out.println("In ma2");
       //A should not be able to access mc2
       obj.mc2();
  }
  
  }
  
  Class B{
  
  //constructor
  Object obj
  public B(Object obj){
   this.obj = obj;
  }
  
  public void mb1(){
  system.out.println("In mb1");
  // B should not be able to access mc1
  obj.mc1();
  }
  
  public void mb2(){
  system.out.println("In mb2");
  obj.mc2();
  }
  
  }
  
  Class C{
  
  public void mc1(){
  system.out.println("In mc1");
  }
  
  public void mc2(){
  system.out.println("In mc2");
  }
  
  }
  
  public static void main(String[] args){
  
  A a = new A(new C);
  B b = new B(new C);
  a.ma1();
  a.ma2();
  
  b.mb1();
  b.mb2();
  }
  </code></pre>
  
  <p>Now I want object 'a' should be able to access mc1 and not mc2
  I want object 'b' should be able to access mc2 and not mc1</p>
  
  <p>Can anyone explain me how to achieve above functionality ?
  Note: Class A, B are my utility classes and its method are used at multiple places in my project. I want to restrict my developer from accessing particular method .</p>
  
  <p>Regards,
  Sand</p>