JSP Java


    
        Using Superclass Variables With Subclassed Objects
    
    
        

Using Superclass Variables With Subclassed Objects


        <%!
            javax.servlet.jsp.JspWriter localOut;
            class vehicle
            {
                public void start() throws java.io.IOException 
                {
                    localOut.println("Starting...
");
                }
            }
            class aircraft extends vehicle
            {
                public void fly() throws java.io.IOException 
                {
                    localOut.println("Flying...
");
                }
            }
            class plane extends aircraft
            {
                public void fly() throws java.io.IOException 
                {
                    localOut.println("Flying...
");
                }
            }
        %>     
        <%
            localOut = out;     
            out.println();
            out.println("Creating a plane object...
");
            vehicle p = new plane();
            p.start();
        %>