Re: pls clarify important concepts...

From: Frances Del Rio (fdr58_at_yahoo.com)
Date: 02/08/05


Date: Tue, 08 Feb 2005 15:42:25 -0500

Bryce wrote:

> On Tue, 08 Feb 2005 09:25:48 -0500, Frances Del Rio <fdr58@yahoo.com>
> wrote:
>
>>I know what it is to instantiate a class (i.e,. create an object of it
>>via the constructor or with "new" keyword), but I'm getting a bit
>>confused now because well, I was reading over my notes last night and
>>this is what I've jotted down: pls tell me if I'm right..
>>
>>-- an ABSTRACT CLASS cannot be instantiated (right?)
> Correct
>
>>-- a FINAL CLASS cannot be subclassed (right?)
> Correct
>
>>I do know what instantiate is, but how is it diff. from subclassing?
>>don't sublcasses inherit methods and vars just like objects?
>
> Instantiate is creating an Object from a Class.

right, that I know..

> For example:
>
> String string = new String();
>
> The above instantiates a new Object string from the class String.
>
> Subclassing is just that:
>
> public class MyClass extends MyBaseClass {
> }
>
>>-- an INTERFACE cannot be instantiated or subclassed -- can only be
>>implemented.. (right?)
>
> That's correct
>
>>pls, what does it mean to IMPLEMENT a class, exactly (or rather, an
>>interface, I suppose)? as opposed to extending it (subclassing it) or
>>instantiating it? am getting a bit confused here..
>
> You don't implement a class. You implement an interface. Think of an
> interface as a contract between that interface and the class that
> implements it.
>
> For example:
>
> public interface MyBusinessInterface {
> public String doWork();
> }
>
> Any class that implements the interface MyBusinessInterface MUST
> implement the method "public String doWork()"
>
> public class MyBusinessClass implements MyBusinessInterface {
> public String doWork() {
> // do some stuff in here, actual implementation of the doWork
> method.
> }
> }
>
> Hope that helps

indeed it has.. thank you very much, Bryce... questions:

I always read if you implement an interface you have to 'implement' all
methods in that interface.. but take an interface like ServletRequest,
from servlet API, it has a million methods, do I have to implement all
methods of this interface if I implement ServletRequest? what is it
exactly to 'implement' a method? can you just 'declare' method (no
stmts inside method, I mean just 'mention' method....;)...)?

usu. servlets open like this:

       public class <ClassName> extends HttpServlet {

this is not the same as implementing, right? when would you want to
'extend' (create subclass) and when wd you want to 'implement'?

I do know what Object is.. and thank you for clarifying things here
also... (namely syntax for sub-classing.. I keep forgetting that this
crates a subclass..

      public class MyClass extends MyBaseClass {
     }

whereas of course this

       Circle myCirle = new Circle();

creates a new obj (instant of a class..)

have more questions, but can't right now, am at work, and very busy..
thank you very much.. Frances



Relevant Pages

  • Re: What about CAO?
    ... So if I have the remoting service set as SingleCall - it's ... it's not possible to instantiate a new ... Now implement this interface on the ... > only on the client). ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: BITS Service
    ... Failed to instantiate BITS Manager interface... ... Analysis of the error code does not suggest a probable cause. ... the Microsoft Knowledge Base at ...
    (microsoft.public.windows.server.general)
  • Re: What about CAO?
    ... One possible solution to this is to extend your shared assembly with an interface for a SAO object. ... It needs a single method which returns a new instance of the CAO, ... Then get a reference of this object on the client via GetObject (you do not instantiate the object, you get a proxy of the existing one from the server - so it will work with the interface only on the client). ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Making a generic data layer
    ... instance of SqlParameter through IDbDataParameter interface. ... you can put your mind at rest :-) ... but of course I can't instantiate an interface. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Does Python really follow its philosophy of "Readability counts"?
    ... I want through a documented interface, suck your module's brains out ... agenda items are supporting, which I thought you were in favour of; ... Subclassing hardly fixes these sorts of problems well. ... Why waste genius programmers on churning out C? ...
    (comp.lang.python)