Home Answers Viewqa Java-Beginners How to access Subclass?

 
 


Virender Kumar
How to access Subclass?
1 Answer(s)      a year and 11 months ago
Posted in : Java Beginners

How to access subclass in java? please tell me the syntex with an example.

View Answers

June 27, 2011 at 5:31 PM


class SuperClass{
    public void hello(){
        System.out.println("Hello World");
    }
}
class SubClass extends SuperClass{
    public void hello(){
        super.hello();
        System.out.println("Welcome");
    }
}
class SubClassExample{
    public static void main(String[] args) 
    {
        SubClass c=new SubClass();
        c.hello();
    }
}









Related Pages:

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.