Actually what you are describing, in C++ terminology, is a PURE virtual
function.  In Java, all methods are equivalent to a C++ virtual function.
    (*Chris*)

----- Original Message -----
From: Carl R. Castro <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 23, 1999 12:10 AM
Subject: Re: virtual functions


> Revathy,
>
> A virtual function in Java is a method that is declared but not
implemented
> (except trivially).  This can be accomplished in three ways.
>
> First, in a class, a method can be declared as "abstract" (a declaration
> keyword), and not implemented.  No braces are used to indicate the method
> body in a declaration, and the semicolon is used to terminate the
> declaration (it being a statement).  For a class containing a function
> declared as "abstract" to compile, the class itself must be declared as
> "abstract".  An abstract class cannot be instantiated; therefore, there is
> no harm in its abstract methods not being implemented.  Instead, a
> ("concrete" - not a keyword) class extending an abstract class - and
> necessarily implementing all of its abstract methods - would be
> instantiated.
>
> Second, a method can be declared in an interface.  All methods declared in
> interfaces are implicitly abstract; really, an interface is just a
construct
> for packaging declarations without packaging implementations.  Class can
be
> declared as implementing interfaces (more than one, in fact), in which
case
> the class must either be declared as abstract, or implement all of the
> methods in the interface.  (Note that while a class can be declared as
> implementing more than one interface - and while interfaces can be
declared
> as extending many other interfaces - a class cannot be declared as
extending
> more than one class.  This means that Java supports multiple interface
> inheritance, but not multiple class inheritance.  This approach provides a
> straightforward, problem-free form of multiple inheritance - for example,
> there would be no conflict in a class implementing more than one interface
> which declared the same method; the class would implement only one version
> of the method.  In languages supporting multiple class inheritance, there
> would be an issue as to which version of the method were inherited.)
>
> Third, a method that has a void return value can be implemented with an
> "empty" method body (indicated with succesive opening and closing braces).
> Note that the method must have a void return value; otherwise it would
fail
> to compile, as it does not return a value (or do anything else) in its
> (empty) method body.  Such methods are also called "no-op" (for "no
> operation") methods; they are actually invoked, but do not execute any
> statements themselves on invocation.  No-op methods are often used in
> support classes for listener interfaces declared in the java.awt.event
> package.  Extending these support classes allows a developer to implement
> only the methods with which he is concerned, and to neglect other methods
> declared in the interface.
>
> I would refer you to the O'Reilly book, "Java in a Nutshell", for clear
and
> accurate information on interfaces, abstract classes & abstract methods,
as
> well as other aspects of Java.
>
> Best wishes for your life & work with Java!
>
> Sincerely,
>
> Carl
>
> Carl R. Castro
> [EMAIL PROTECTED]
> (415) 351-CARL
>
>
>
>
>
>
> -----Original Message-----
> From: Revathy Ravi <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date: Monday, March 22, 1999 11:04 PM
> Subject: virtual functions
>
>
> >Sir,
> >How Virtual function concept is implemented in Java.
> >
> >
> >  Revathy R.
> >
>
>___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources: http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to