<HTML>
<HEAD>
<TITLE>Overriding Methods in derived class</TITLE>
</HEAD>
<BODY>
<H1>Overriding Methods</H1>
<%!
javax.servlet.jsp.JspWriter localOut;
class BaseClass
{
public void print() throws java.io.IOException
{
localOut.println("print in base...<BR>");
}
}
class DerivedClass extends BaseClass
{
public void print() throws java.io.IOException
{
localOut.println("print in Derived class...<BR>");
}
}
%>
<%
localOut = out;
out.println("Creating an animal object...<BR>");
BaseClass a = new BaseClass();
a.print();
out.println();
out.println("Creating a trout object...<BR>");
DerivedClass t = new DerivedClass();
t.print();
%>
</BODY>
</HTML>
|