Results 1 to 8 of 8
Thread: interface vs abstract classes
- 11-13-2008, 02:56 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 58
- Rep Power
- 0
interface vs abstract classes
Hey is there a good website, that explains using classes implementing interfaces, with the help of a full explained code. I have gone through website, but wasnt of much help. I have questions as to how to create a driver program like 'public static void main()'. There are several other questions as such about if a function is written in the interface; how to call objects of the class as input.
Please suggest.
-
1) Have you gone through the Sun tutorials on this subject? That's always where I start.
2) Please go into further details on just what you mean by a "driver program". You mention a static method, and as far as I know, static doesn't work with interfaces.
3) Have you tried creating an interface and used the interface name itself as a parameter to one of its methods? If so, did it compile?
- 11-13-2008, 03:05 PM #3
Member
- Join Date
- Sep 2008
- Posts
- 58
- Rep Power
- 0
I have not done anything. I just want to learn interfaces first, before implemeting. Also, how to call functions(i.e) how to create a driver program.
Ive gone through sun tutorial, but it just gives a brief introduction, not to the depth of what I need to know.
-
Again, what the heck do you mean by a "driver" program. Please go into a bit more detail, with examples if you can think of any as I'm not clear on just what you're trying to do.
-
Also, the Interface Tutorial that I've study at the Sun site seemed to go into quite a bit of detail, and in fact though it is all I've ever studied on the subject I feel quite comfortable with using this construct. Are you sure that you've been through the same tutorial as I? You can find it here:
Interfaces (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance)
- 11-13-2008, 06:10 PM #6
Member
- Join Date
- Sep 2008
- Posts
- 58
- Rep Power
- 0
In a regular program that deals with basic class, I will have a main class(driver program) that initializes values, calls functions.
how could I do this with an interface?Java Code:class XXX { constructor() function a(){}; function b(){}; main() { function a(); function b(){}; } }
Java Code:interface XXX { function a(); function b(); } class YYY implements XXX { constructor() function a(){}; function b(){}; }
-
I'm sorry, it may be me, but I'm still not clear what the hang up is. Your driver I suppose would have variables of the interface type, would initialize it with a concrete class that implements the interface, and then would call the methods as needed.
- 11-16-2008, 08:22 PM #8
Member
- Join Date
- Sep 2008
- Posts
- 58
- Rep Power
- 0
I found a website that gives code examples to what I was asking.
Java Source Code Examples - Problems and solutions
Similar Threads
-
difference between Abstract and interface
By mrark in forum New To JavaReplies: 3Last Post: 11-07-2009, 04:20 AM -
Interface and Abstract Class
By kian_hong2000 in forum New To JavaReplies: 1Last Post: 08-27-2008, 02:22 PM -
Interface Vs Abstract Class
By javarishi in forum New To JavaReplies: 5Last Post: 06-15-2008, 05:43 AM -
Inverfaces vs Abstract Classes
By ravian in forum New To JavaReplies: 1Last Post: 11-28-2007, 09:53 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks