Using Superclass Variables With Subclassed Objects : Class in JSP Page « JSP « Java Tutorial






<HTML>
    <HEAD>
        <TITLE>Using Superclass Variables With Subclassed Objects</TITLE>
    </HEAD>

    <BODY>
        <H1>Using Superclass Variables With Subclassed Objects</H1>

        <%!
            javax.servlet.jsp.JspWriter localOut;

            class BaseClass
            {
                public void start() throws java.io.IOException 
                {
                    localOut.println("Starting...<BR>");
                }
            }

            class DerivedClass1 extends BaseClass
            {
                public void fly() throws java.io.IOException 
                {
                    localOut.println("Flying...<BR>");
                }
            }

            class DerivedClass2 extends DerivedClass1
            {
                public void fly() throws java.io.IOException 
                {
                    localOut.println("Flying...<BR>");
                }
            }
        %>     
        <%
            localOut = out;     

            out.println();
            out.println("Creating a DerivedClass2 object...<BR>");
            BaseClass p = new DerivedClass2();
            p.start();
        %>
    </BODY>
</HTML>








23.14.Class in JSP Page
23.14.1.Using Inheritance
23.14.2.Using Restricted Access
23.14.3.Calling Superclass Constructors
23.14.4.Using Parameterized Constructors
23.14.5.Working With Constructors and Inheritance
23.14.6.Overloading Methods
23.14.7.Overriding Methods in derived class
23.14.8.Using Superclass Variables With Subclassed Objects
23.14.9.Runtime Polymorphism
23.14.10.Using Abstract Classes
23.14.11.Creating a Java Interface