Re: pls clarify important concepts...
From: Frances Del Rio (fdr58_at_yahoo.com)
Date: 02/08/05
- Next message: Frances Del Rio: "Re: pls clarify important concepts..."
- Previous message: Donna: "Help: incomparable types: boolean and char error in code"
- In reply to: Bryce: "Re: pls clarify important concepts..."
- Next in thread: Frances Del Rio: "Re: pls clarify important concepts..."
- Reply: Frances Del Rio: "Re: pls clarify important concepts..."
- Reply: Bryce: "Re: pls clarify important concepts..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Frances Del Rio: "Re: pls clarify important concepts..."
- Previous message: Donna: "Help: incomparable types: boolean and char error in code"
- In reply to: Bryce: "Re: pls clarify important concepts..."
- Next in thread: Frances Del Rio: "Re: pls clarify important concepts..."
- Reply: Frances Del Rio: "Re: pls clarify important concepts..."
- Reply: Bryce: "Re: pls clarify important concepts..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|