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();

}
  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???
        }

}

View Answers

February 4, 2011 at 2:57 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


February 4, 2011 at 3:30 PM

thks for the ans sir but u change the object creation in main class but i just want ti know that there is any way to call class without creating its object in main class,please give the ans sir









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
inhertence
multilevel inhertence
multiple inheritance.
multiple inheritance.  hello, can java support multiple inheritance???   hi,ADS_TO_REPLACE_1 java does not support multiple inheritance
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  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  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
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
Add multiple UIBarButtonItem
Add multiple UIBarButtonItem  add multiple uibarbuttonitem
mail with multiple attachments
mail with multiple attachments  code for sending mail with multiple attachments in jsp
uinavigationcontroller add multiple buttons
uinavigationcontroller add multiple buttons  How to add multiple buttons to the UINavigationController
multiple resultset in one resultset
multiple resultset in one resultset  how to retrive multiple resultsets in one resultset in java.? plz help
multiple select values
multiple select values   can you provide an example for multiple select values for html:select tag
multiple selections list in Struts
multiple selections list in Struts  How to create a multiple selections list in Struts? and retrive seleted values
insert multiple selection - Java
insert multiple selection - Java  how to insert multiple selection values from html into database using servlets
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
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
multiple submits, single form.
multiple submits, single form.  is it possible to use multiple submit buttons in a single form?   Thank you
select tag multiple values
select tag multiple values   I want to insert multiple values in database which i have selected from select tag
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
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
Data from multiple ResultSets?
Data from multiple ResultSets?  hello, How can I get data from multiple ResultSets?   Hi,ADS_TO_REPLACE_1 You can iterate the ResultSet separately and get the required data. Thanks
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
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 fields in hashtable
multiple fields in hashtable  Hai,could anyone help me to implement the object car fields speed,make & color in Hash table
TO connect multiple database
TO connect multiple database  How to connect several database from a single application in java depending upon the user input it will connect to that database
Reading and writting multiple files
Reading and writting multiple files  how can i read and write say two different files at the same time using threads
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
Multiple implementaion of datepicker.
Multiple implementaion of datepicker.  Hello Sir I am using date-picker in my web page. But i need to put date-picker on multiple text fields... function: $('.calendar').datepicker(); Using it that way for multiple calendar
autocomplete displaying multiple fields
autocomplete displaying multiple fields  How can I create an autocomplete with three field (name, id, phone). Placing the phone field in the appropriate input field but selecting the name field into the 'calling' input box
multiple language selection
multiple language selection  Hi how can i do a java program using swing that changes the language like malayalam/tamil etc with languages on a drop down menu
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Multiple upload - JSP-Servlet
Multiple upload  Hello everyone and Deepak i am using jsp and mysql I am using the program published on roseindia.net of Multiple upload and i am facing an error as given below please help and reply soon this is my 8th
multiple language support iPhone
multiple language support iPhone  Is it possible to create an application in iPhone that can support multiple languages.   Yes, iPhone/iPad applications support the multi language applications. To create your iPhone
Upload and Download multiple files
Upload and Download multiple files  Hello Sir/Madam, I need a simple code for upload and download multiple files(it may be image,doc and txt)which has to be store in database and also retrieve the file from database
sendRedirect to multiple links
sendRedirect to multiple links  hello , In my servlet page , i'm using response.sendRedirect("http://ubaid.tk/sms/sms.aspx?uid="+fromNumber+"&... the above line. i want redirect to multiple links simultaneously. anyone help me
Handling multiple buttons in HTML Form
Handling multiple buttons in HTML Form  How to handle Handling multiple buttons in HTML Form
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
iPhone SDK Multiple UIButton
iPhone SDK Multiple UIButton  In my iphone SDK program.. i wanted to create multiple UIButton programatically. I know how to create button and i have... requirement is to create multiple UIButton's according to number of items available
Creating Multiple ArrayList
Creating Multiple ArrayList   I want to create multiple ArrayList . import java.util.*; class ArrayListNames{ public static void main(String args[]){ //here i want to create 10 arraylists of type string
distributed tensorflow multiple gpu
distributed tensorflow multiple gpu  Hi, I am beginner in Data...: distributed tensorflow multiple gpu Try to provide me good examples or tutorials links so that I can learn the topic "distributed tensorflow multiple
Criteria with Multiple Tables - Hibernate
Criteria with Multiple Tables  I am using Hibernates Criteria. How to get Joins using Criteria? e.g. instead of below query i want to use criteria then How i can? select user from TeamsUserEntity

Ads