×

Loading...

We can use inherited methods only in the definition of the sub class.

jabber (jabber)
This is a flaw in Java. Once a subclass extends a superclass, there is
NO WAY to use the methods of the super class. We can use inherited methods ONLY
in the definition of the subclass. Please look at the following toy code.


class Daddy{
public void smoke(){
System.out.println("Cigar! Cigar!");
}
}

class Sonny extends Daddy{
public void smoke(){
//This calling of inherited methods is OK!
super.smoke();
System.out.println("Marlboro! Marlboro!!");
}
}

public class Test{
Sonny sonny = new Sonny();
sonny.smoke();
// The following code does not work!
//sonny.super.smoke();
}
}
(#11898@0)
2000-10-24 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: java problem

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论