multilevel inhertence

Ads
 

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

Ads









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
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
Advertisements
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... supports three types of inheritance: Simple inheritance Multilevel..., int q){ x=p; y=q; return(0); } void Show(){ System.out.println(x
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
inheritance Multilevel inheritance. Hierarchical inheritance Note: 1. subclass...: Multilevel inheritance: The Multilevel inheritance is inheriting features... be achieved by interface. In this example we have used multilevel inheritance
Inheritance in Java
of inheritance in Java: Simple Inheritance Multilevel Inheritance... class. Multilevel Inheritance: Multiple Inheritance is when a subclass is derived... for it's just above (parent) class. Multilevel inheritance can go up to any number
Concept of Inheritance in Java
. Multilevel Inheritance In Multiple Inheritance, a parent class is extended.... Multilevel inheritance can go up to any number of levels. Java does not support
Inheritance
; Multilevel Inheritance Pictorial Representation of Simple and Multilevel... Multilevel Inheritance Simple Inheritance When a  subclass is derived...; int y;   int get(int p, int q){  
Inheritance
; Multilevel Inheritance Pictorial Representation of Simple and Multilevel... Multilevel Inheritance Simple Inheritance When a  subclass is derived...;   int y;   int get(int p, int q
Inheritance,Inheritance in Java,Java Inheritance
; Multilevel Inheritance Pictorial Representation of Simple and Multilevel... Multilevel Inheritance Simple Inheritance When a  subclass is derived...;   int y;   int get(int p, int q
Trading Portal Development Services India
and Sell offers, Multilevel categories for convenient browsing Category..., Multilevel Categories management console allows to add / edit / remove
Java Features
and by this way multilevel inheritance is acheived . It is used foe message passing
Inheritance Example In Java
. These are as follows : Single Inheritance Multilevel Inheritance
Portal Development Services,Portal Development Service
-on, profiling, multilevel membership, user administration, user behavior
An Overview of Java      Java is a programming language      Java is Object Oriented Programming
Multilevel Inheritance  Java does not support multiple

Ads