0% found this document useful (0 votes)
37 views

Abstract

This document discusses using abstract classes in Java. An abstract class a is defined with an abstract method getText() that returns a String and throws an IOException. A concrete subclass b overrides the getText() method to return the string "Hello from JSP!". A new instance of b is created and its printem() method is called, which prints the result of getText() to the output stream.

Uploaded by

faruk409
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Abstract

This document discusses using abstract classes in Java. An abstract class a is defined with an abstract method getText() that returns a String and throws an IOException. A concrete subclass b overrides the getText() method to return the string "Hello from JSP!". A new instance of b is created and its printem() method is called, which prints the result of getText() to the output stream.

Uploaded by

faruk409
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

<HTML> <HEAD> <TITLE>Using Abstract Classes</TITLE> </HEAD> <BODY> <H1>Using Abstract Classes</H1> <%! javax.servlet.jsp.

JspWriter localOut; abstract class a { abstract String getText() throws java.io. IOException; public void printem() throws java.io.IOEx ception { localOut.println(getText()); } } class b extends a { String getText() throws java.io.IOExcepti on { return "Hello from JSP!"; } } %> <% localOut = out; b bObject = new b();

bObject.printem(); %> </BODY> </HTML>

You might also like