Home Answers Viewqa Java-Beginners multilevel inhertence

 
 


amit pathak
multilevel inhertence
1 Answer(s)      2 years and 3 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???
        }

}

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 Pages:
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
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
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
Fresher-Trainee
Fresher-Trainee  a java program to calculate the area of different shapes using Multilevel Inheritance
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
java - Java Beginners
. * Simple Inheritance * Multilevel Inheritance Simple inheritence...("B"); } Multilevel Inheritence : class A { int x; int y
Inheritance,Inheritance in Java,Java Inheritance
; Multilevel Inheritance Pictorial Representation of Simple and Multilevel... Multilevel Inheritance Simple Inheritance When a  subclass is derived...;} } Multilevel Inheritance It is the enhancement of the concept of inheritance. When
Inheritance
; Multilevel Inheritance Pictorial Representation of Simple and Multilevel... Multilevel Inheritance Simple Inheritance When a  subclass is derived...;} } Multilevel Inheritance It is the enhancement of the concept of inheritance. When
Inheritance
; Multilevel Inheritance Pictorial Representation of Simple and Multilevel... Multilevel Inheritance Simple Inheritance When a  subclass is derived...;} } Multilevel Inheritance It is the enhancement of the concept of 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
Catching Normal Exceptions
clause. Hence due to this multilevel catch handlers can be provided which
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
Portal Development Services,Portal Development Service
-on, profiling, multilevel membership, user administration, user behavior
Master Java In A Week
Inheritance Multilevel Inheritance  Java
NetBeans IDE
recommended to create a named package. you can create multilevel packages

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.