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 inhertencemultilevel 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 inheritancemultilevel 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 BeginnersMultilevel 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 InheritanceJava :
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 javaMultilevel 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. "
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-TraineeFresher-Trainee a java program to calculate the area of different shapes using
Multilevel Inheritance
interfaceinterface 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
java - Java Beginnersjava 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
Java Features object treated like another
object and by this way
multilevel inheritance