|
-
July 22nd, 2005, 12:54 AM
#1
defination of interface,abstract
I know something about interface, abstract
But actually I want to know
When a interviewer ask or in a seminar, in a class,
1.what is interface?
2.what is abstract?
3.what are the definition of interface and abstract in the case of client/server and in core java part
4.difference is the difference of interface and abstract
5.why interface
6.why abstract ETC
please give me details theory, example, any link etc
Thanks & Regards
Manoj
-
July 22nd, 2005, 09:50 AM
#2
Re: defination of interface,abstract
You probably need a good book or a link for this, but here is a summary:
Interface
Any class that implements an interface must contain each of the method names in the interface. An interface is simply a list of method names. You use it to enforce the way that the object is referred to. If the interface does not change, the way the object is used will not change even though the class that extends the interface may change.
Abstract Class
This class is designed to be extended by another class. You cannot actually make objects of this class.
Abstract Method
When a class extends another class with abstract methods, all abstract methods must be re-written.
-
July 23rd, 2005, 08:48 PM
#3
Re: defination of interface,abstract
An interface is a collection of methods (doesn't provide the functionality) that any class implementing must use. An interface can be empty (examples are cloneable and serializable). An interface contains a return type and method name of any method, together with any arguments that this must take.
An abstract class cannot be instantiated (i.e. you can't create an abstract class - "new AbstractClass();" would not be allowed). Abstract classes are used where there are several classes all using a similar features - abstract methods in an abstract class can be empty (left of the concrete class to come up with the functionality), or it can provide functionality - therefore unless any concrete class inheriting from the abstract class overrides the method, they will all use the functionality the abstract class defines.
-
July 23rd, 2005, 10:48 PM
#4
Re: defination of interface,abstract
An interface is sometimes called an "ultimate abstract class" because it (usually) contains nothing but implicit abstract methods. In general, an interface defines a set of behaviors for class's that implement the interface regardless of where the class is in the inheritance hierarchy. An abstract class defines behaviors for all class's that derive from the abstract class. Abstract class's also sometimes have some implementation code that subclass's can use.
Hungarian notation, reinterpreted? http://www.joelonsoftware.com/articles/Wrong.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|