package Test;
public class hello {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String arg1="world!";
System.out.printf("hello %s\n", arg1);
CBase obj;
obj=new CDerive1();
obj.say_sth();
obj.say_hello();
obj=new CDerive2();
obj.say_sth();
obj.say_hello();
}
}
abstract class CBase{
public abstract void say_sth();
public void say_hello()
{
System.out.printf("CBase::say_hello\n");
}
}
class CDerive1 extends CBase{
@Override
public void say_sth()
{
System.out.printf("CDerive1\n");
}
}
class CDerive2 extends CBase{
@Override
public void say_sth()
{
System.out.printf("CDerive2\n");
}
}
hello world!
CDerive1
CBase::say_hello
CDerive2
CBase::say_hello