Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Sunday, December 2, 2007

How to use Superclass Variables With Subclassed Objects in 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();
%>

No comments: