Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners multiple inhertence
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


amit pathak
multiple inhertence
1 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners


package start;

class A { protected void a() //a method in A { System.out.println("Class A"); } }

class B extends A { public B() { super();

}
  public void a()
  {
      super.a();
         System.out.println("Class B");    //A's a method overridden in B
  }

}

class C extends B {

public void a()                     //B's a method overridden in C
  {
    super.a();
         System.out.println("Class C");
  }

}

public class M {

        public static void main(String arg[])
        {

             //Creating a oblect of C
             C oC=new C();

             oC.a(); 

             //My Question = How to call A's in main an dont wanna print B an C???
        }

}


Advertisement
View Answers

February 4, 2011 at 2:56 PM


Hi Friend,

Try this:

class A {
    protected void a(){
    System.out.println("Class A");
    } 
    }
class B extends A {
    public B() {
    super();
  }
  public void a(){
      super.a();
         System.out.println("Class B");    
  }
}
class C extends B {
public void a(){
    super.a();
    System.out.println("Class C");
  }
}
public class M {
        public static void main(String arg[]){
             A a=new A();
             a.a();
        }
}

Thanks



Related Tutorials/Questions & Answers:
multiple inhertence
multiple inhertence  package start; class A { protected void a() //a method in A { System.out.println("Class A"); } } class B extends A { public B() { super
multiple inhertence
multiple inhertence  package start; class A { protected void a() //a method in A { System.out.println("Class A"); } } class B extends A { public B() { super
Advertisements
multiple inheritance.
multiple inheritance.  hello, can java support multiple inheritance???   hi, java does not support multiple inheritance
multiple inheritance
multiple inheritance  why java doesn't support multiple inheritance? we can achieve this by using interface but not with classes? what is the main reason that java community implemented like
multiple inheritance
multiple inheritance  Class A extends Class B but Class A also inherit Super Class Object so it is multiple inheritence give reason in support of your answer
Multiple Inheritance
Multiple Inheritance  All are saying java doesn't support multiple inheritance but by default Object class is super class for all the user defined... class so java any how do multiple inheritance? Can you please explain
Multiple Inheritance
Multiple Inheritance  Why Java Doesn't have Multiple Inheritance It is Advantage or Disadvantage.........   Hi Friend, When we extends... and inconsistencies Java does not support Multiple Inheritance. Thanks
Add multiple UIBarButtonItem
Add multiple UIBarButtonItem  add multiple uibarbuttonitem
uinavigationcontroller add multiple buttons
uinavigationcontroller add multiple buttons  How to add multiple buttons to the UINavigationController
mail with multiple attachments
mail with multiple attachments  code for sending mail with multiple attachments in jsp
insert multiple selection - Java
insert multiple selection - Java  how to insert multiple selection values from html into database using servlets
multiple select values
multiple select values   can you provide an example for multiple select values for html:select tag
multiple resultset in one resultset
multiple resultset in one resultset  how to retrive multiple resultsets in one resultset in java.? plz help
multiple selections list in Struts
multiple selections list in Struts  How to create a multiple selections list in Struts? and retrive seleted values
Remove multiple elements in arraylist
Remove multiple elements in arraylist   how can we remove multiple values in arrayList? only remove method we used for single remove.but i want to delete multiple value in arrayList
struts2 select tag multiple
struts2 select tag multiple  struts2 select tag multiple
select tag multiple values
select tag multiple values   I want to insert multiple values in database which i have selected from select tag
multiple submits, single form.
multiple submits, single form.  is it possible to use multiple submit buttons in a single form?   Thank you
multiple choice questions
multiple choice questions  how can i store 10 multiple choice questions in one class with using java language
multiple choice questions
multiple choice questions  how can i implement the program to store multiple questions in class with using core java concepts
query regarding multiple select
query regarding multiple select  i have a select in jsp with multiple options.When i select multiple values i am not able to insert it into database and how do i retrieve them..please help me with an example code
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
Data from multiple ResultSets?
Data from multiple ResultSets?  hello, How can I get data from multiple ResultSets?   Hi, You can iterate the ResultSet separately and get the required data. Thanks
multiple inheritance - Java Beginners
multiple inheritance  can u implement one class to more than one interface
multiple inheritance - Java Beginners
multiple inheritance  Why java does not support Multiple Inheritance?  First of all the question is wrong the correct one is......... Q)why java classes does not support Multiple Inheritance? JAVA CLASSES ONLY
multiple records on same panel
multiple records on same panel  i have multiple access of records and i want to display all of them at one panel.Each time a new panel opens for a keyrecord , i want just to show records on same panel or frame, whatever u can
Multiple File Upload in PHP
Multiple File Upload in PHP  Hi, I am beginner in PHP scripting language. I am very interested to learn PHP application. So, can anyone explain or provide related reference about how to Multiple file upload in PHP. Thanks
Reading multiple xml files
Reading multiple xml files  How can we read many xml files from a folder? The same procedure as that of "listfiles
Advertisements
 

 

 

DMCA.com