Diff B/W Interface & Abstract class
Hi frnds,
Can any body solve my qustion,
In Interface containing abstract methods right......
and
Abstract class also containing abstract methods right....
so both are using abstract methods.
Then why Interface or Abstract class ?????? what's the diff
Let me know at least 3 resons plz...
Thanks & Regards,
Sreekanth S.
Re: Diff B/W Interface & Abstract class
Diff B\w Interface And abstract Class:
1.Abstract class contains abstract method but interface did't contains abstact method
2.modifier for abstact class can be public and internal
for interface modifier can be public and abstacr
3.it's an incompleate class but interface is not a class it is treated as class
for abstact class keyword abstact is used but for inteface , keyword interface is used .
i think so it will be helpful for u .
thanks
G.S.Rathore
Re: Diff B/W Interface & Abstract class
Hi Rathore,
Thanks for your give advise. But I have one doubt,
when you says interface did't contains abstract method , but in Interface by default all methods are public abstract. Is it right or wrong.
plz solve this doubt.
[B]Thanks & Regards,
Sreekanth S[/B]
[QUOTE=gyanrathore3438;30234]Diff B\w Interface And abstract Class:
1.Abstract class contains abstract method but interface did't contains abstact method
2.modifier for abstact class can be public and internal
for interface modifier can be public and abstacr
3.it's an incompleate class but interface is not a class it is treated as class
for abstact class keyword abstact is used but for inteface , keyword interface is used .
i think so it will be helpful for u .
thanks
G.S.Rathore[/QUOTE]
Re: Diff B/W Interface & Abstract class
you can define the body of abstract method in abstract class but u cannot define the body of method in interface.
Re: Diff B/W Interface & Abstract class
In abstract class there is no necessity that, all the methods should be abstract. there can be both abstract and concrete methods.
But in interface all the methods are abstract. No method should be concrete.
Re: Diff B/W Interface & Abstract class
Hi Sree,
Abstract class and interfaces are completely different.
1) In an abstract class, you may also have some concrete methods( fully implemented. It can have all its methods as concrete, yet be declared as abstract) , but in an interface, all the methods ought to be abstract.
2)Abstarct class can never be instantiated, but you can indirectly instantiate an interface by instantiating the class which implements it and then use the its methods.
Re: Diff B/W Interface & Abstract class
need study guide for weblogic?beginning learners
Re: Diff B/W Interface & Abstract class
Abstract classes are intended to be used base class. An abstract class cannot be instantiated.
A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
Abstract and sealed (class cannot be inherited) modifier can’t work together.
An abstract class can have abstract members as well non-abstract members. But in an interface all the members are implicitly abstract and all the members of the interface must override to its derived class.
Abstract classes can have protected members, static members.
The members of the interface are public with no implementation
An interface can inherit from one or more base interfaces.
A class can inherit one or more interfaces, but only one abstract class.