Hi;
It's my first post since I am a new member of this group.
As I understood from your question; you meant ABSTRACT classes versus
interfaces. OK.

Java uses interfaces for multi-inheritance; a useful capability in C++
that could turn into a night mare if something goes wrong; especially
the coffee you was drinking!!!! :-)
But the abstract classes by the way are used for polymorphism.
let see the following examples;

public class Test {
    public static void main(String[] args) {
        Person p;
        Employee e = new Employee();
        Programmer pr = new Programmer();
        p = e;
        System.out.println(p.getFullName());
        p = pr;
        System.out.println(p.getFullName());
    }
}

abstract class Person {
     abstract public String getFullName();
}

class Employee extends Person {
     public String getFullName() {
         return "Ali SOMEONE";
     }
}

class Programmer extends Person {
     public String getFullName() {
         return "Ali SOMEOTHERONE";
     }
}

would result in

Ali SOMEONE
Ali SOMEOTHERONE


but for the interface; i should think and search to find a good
example. note me if anything goes wrong there since i'm also a
beginner in java world.

have a good time!


On Dec 16, 7:51 pm, nn roh <[email protected]> wrote:
> Hi all,
>
> Thanks a lot for sharing ideas and help in this group :)
>
> I want more examples on using abstract classes and interface ... ?
>
> Thanks,

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to