Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Sunday, December 2, 2007

java code for Overriding Methods 2



Overriding Methods



Overriding Methods



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

class animal
{
public void breathe() throws java.io.IOException
{
localOut.println("Breathing...
");
}
}

class trout extends animal
{
public void breathe() throws java.io.IOException
{
localOut.println("Gilling...
");
}
}
%>
<%
localOut = out;

out.println("Creating an animal object...
");
animal a = new animal();
a.breathe();

out.println();
out.println("Creating a trout object...
");
trout t = new trout();
t.breathe();
%>

No comments: