On Dec 17, 4:42 am, nn roh <[email protected]> wrote:
> Thank you all , ii have been read your posts , its really helpful :)
> What i am looking for is more practical examples that help me to think
> better with oop .
I hope you like coffee. My thought:
interface Milkable{
void addMilk();
}
abstract class Drink{
String name;
}
class Coffee extends Drink implements Milkable{
Coffee(String $name){
name=$name;
}
void addMilk(){
name=name+" with milk";
}
}
Note: I have not really written anything with an interface nor an
abstract class. Do feel free to correct me.
>
> regards,
>
> Nada
>
>
>
> On Wed, Dec 16, 2009 at 11:16 PM, Retnuh <[email protected]> wrote:
> > Do you know what a Class is? An actual Concrete Class that is used to
> > create objects.
> > If you know about that, then an Abstract Class is a Class that is not
> > Concrete, meaning it does not create objects. I has all the same features a
> > normal (concrete) class has, but it has the keyword "abstract". In an
> > abstract class, you are allowed to have methods that are not defined with
> > the logic inside them; except just simply defined like: public void
> > setName(String name);
> > Now for an Interface. You can only define the method and attributes
> > (instance variables) like: public String name; public int age; public
> > String getName(); and so on. Then you can implement an Interface and/or
> > extend an Abstract Class.
> > See the good thing about Interfaces are, you can implement numerous ones.
> > You can only extend one Class whether it is a Concrete Class or an Abstract
> > Class.
> > However, if you implement an Interface, you must.... MUST define (use)
> > every method within your Class that implements it/them.
>
> > Now if you need help explaining why you would use an Abstract Class or an
> > Interface; well that is because of Inheritance, Abstraction and
> > Polymorphism. First learn what those three things mean and then look into
> > Abstract Classes and Interfaces.
>
> > What I have just told you here is the cut and dry of the meanings of both.
> > But now you have a good understanding of the differences of them, so read
> > more on these two and soon.... You will be a Coding Phenomenon <-- I know
> > this is Corny, but hey... You need excitement and a giggle here and there.
>
> > Stephen
>
> > nn roh 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
--
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