multilevel inhertence

multilevel 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: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:
multilevel inhertence
multilevel inhertence  package start; class A { protected void a() //a method in A { System.out.println("Class A"); } } class B extends A { public B
inhertence
Advertisements
multilevel inheritance
multilevel inheritance  import java.io.*; public class Employee { int eid; String ename; void tostring() { System.out.print("Enter Your ID:"); eid=Integer.parseInt(in.readLine()); System.out.print("Enter Your
Multilevel inheritance - Java Beginners
Multilevel inheritance  Dear Sir, I'm posting you another question for which I need a more explanatory java coding(A lengthy one with more classes... to multilevel inhertance " Thank You
ModuleNotFoundError: No module named 'multilevel-mesa'
ModuleNotFoundError: No module named 'multilevel-mesa'  Hi, My... named 'multilevel-mesa' How to remove the ModuleNotFoundError: No module named 'multilevel-mesa' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'multilevel-panels'
ModuleNotFoundError: No module named 'multilevel-panels'  Hi, My... named 'multilevel-panels' How to remove the ModuleNotFoundError: No module named 'multilevel-panels' error? Thanks   Hi, In your
Java : Multilevel Inheritance
Java : Multilevel Inheritance This section contains concept of multilevel Inheritance in java. Multilevel Inheritance : In multilevel inheritance more than... can say multilevel inheritance create one-to-one ladder. Now you can access
Multilevel Inheritance in java
Multilevel Inheritance in java We are going to discuss about multilevel inheritance in java. The Multilevel inheritance is inherit of classes more than two classes. We use multilevel inheritance to create one-to-one ladder. "
ModuleNotFoundError: No module named 'binomia_translatable_multilevel_menu'
ModuleNotFoundError: No module named 'binomia_translatable_multilevel_menu...: ModuleNotFoundError: No module named 'binomia_translatable_multilevel_menu' How to remove the ModuleNotFoundError: No module named 'binomia_translatable_multilevel
multiple inhertence
multiple inhertence
Inheritance program in java
and Multilevel Inheritance in Java. Inheritance is an OOPS (Object Oriented... Multilevel inheritance Hierarchical inheritance ADS_TO_REPLACE_2..._TO_REPLACE_3 class A { int x; int y; int get(int p, int q){ x=p; y=q; return(0
Fresher-Trainee
Fresher-Trainee  a java program to calculate the area of different shapes using Multilevel Inheritance
interface
interface  why do we need interface in java..if it`s usefull for to obtain multiple inheritance in the sense how it gonna be achieved...and i can achieve multiple inhertitance by extends one class with another (by multilevel
Inheritance in Java with example
, they are: Simple inheritance Multilevel inheritance. Hierarchical inheritance Note...(25,26); text.Show(); } } Output: Multilevel inheritance: The Multilevel inheritance is inheriting features of more than one class
Inheritance in Java
There are two types of inheritance in Java: Simple Inheritance Multilevel... and it's parent class.ADS_TO_REPLACE_2 Multilevel Inheritance: Multiple... works as the child class for it's just above (parent) class. Multilevel
java - Java Beginners
. * Simple Inheritance * Multilevel Inheritance Simple inheritence : class A { int x; int y; int get(int p, int q){ x=p; y=q; return(0...("B"); } Multilevel Inheritence : class A { int x; int y
Concept of Inheritance in Java
as single inheritance or one level inheritance. Multilevel Inheritance..., the former becomes the parent class for later. Multilevel inheritance can go up
Inheritance
Inheritance   Multilevel Inheritance Pictorial Representation of Simple and Multilevel InheritanceADS_TO_REPLACE_2 Simple Inheritance Multilevel Inheritance Simple Inheritance
Inheritance
Inheritance   Multilevel Inheritance Pictorial Representation of Simple and Multilevel InheritanceADS_TO_REPLACE_2 Simple Inheritance Multilevel Inheritance Simple Inheritance When
Inheritance,Inheritance in Java,Java Inheritance
Inheritance   Multilevel Inheritance Pictorial Representation of Simple and Multilevel InheritanceADS_TO_REPLACE_2 Simple Inheritance Multilevel Inheritance Simple Inheritance When
java - Java Beginners
java  what diffarencs between an abstractclass and aninterface (except anabstract can inherit multilevel classes where as aninterface can inherit multiple classes)  Hi friend, Some points to be memember difference
Concept error - WebSevices
features. Joomla! main benefits: * Multiuser and Multilevel environment
Trading Portal Development Services India
uploading for Product Catalogue and Sell offers, Multilevel categories... for admin to know how site is going, Multilevel Categories management console
Catching Normal Exceptions
clause. Hence due to this multilevel catch handlers can be provided which
Java Features
object treated like another object and by this way multilevel inheritance
Inheritance Example In Java
types of inheritance. These are as follows : Single Inheritance Multilevel
Portal Development Services,Portal Development Service
, multilevel membership, user administration, user behavior tracking, reporting
Master Java In A Week
_TO_REPLACE_5 Simple Inheritance Multilevel
An Overview of Java      Java is a programming language      Java is Object Oriented Programming
etc. Simple Inheritance Multilevel

Ads