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



Home Answers Viewqa Java-Beginners multilevel inhertence
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


amit pathak
multilevel inhertence
1 Answer(s)      3 years and 11 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: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
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
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. "
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
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
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
. 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,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
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){  
Catching Normal Exceptions
clause. Hence due to this multilevel catch handlers can be provided which
Concept error - WebSevices
features. Joomla! main benefits: * Multiuser and Multilevel environment
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
Trading Portal Development Services India
and Sell offers, Multilevel categories for convenient browsing Category..., Multilevel Categories management console allows to add / edit / remove
Inheritance Example In Java
. These are as follows : Single Inheritance Multilevel Inheritance
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
this, super etc. Simple Inheritance Multilevel
 

 

 

DMCA.com