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



Home Answers Viewqa Java-Beginners multiple inhertence

Have Programming Question? Ask it here!
 
 
 


amit pathak
multiple inhertence
2 Answer(s)      3 years and 6 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: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
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
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
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
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...: $('.calendar').datepicker(); Using it that way for multiple calendar fields works
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 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
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
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
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
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
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
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
Multiple Validations on jTestFields
Multiple Validations on jTestFields  Hi, I am working on an window application in which I have to validate the data of text fields, like if textbox1 is empty then it prompt for filed should not be empty, and if data is entered
Renaming multiple files
Renaming multiple files  Hi, I have number of files in a directory. Files are named as: 1DeoyaRohit0705$.mp4,2DeoyaRohit0705$.mp4, 3_DeoyaRohit0705$.mp4. .... Now I wanted to rename these files as: 1RohitBBorse.mp4
Multiple select box
Multiple select box  Hi, I need help in code for multiple select box. The multiple select box should be populated with the db values.The selection done in the multiple select box is to be moved to the text area provided a add
Multiple url handling
Multiple url handling  I want to pick URLs from excel/CSV file and assign those urls to String variable and use that string variable to open the specified url from browser. I have written code to open browser using selenium
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
Advertisements
 

 

 

DMCA.com