I know what is abstract class and interface, but i want to know the real time example where we use these both
[b]Question asked by visitor Bhuvaneswari[/B]
Printable View
I know what is abstract class and interface, but i want to know the real time example where we use these both
[b]Question asked by visitor Bhuvaneswari[/B]
u mean a real world or real time.Real time has a different meaning and i guess java is not used for real time applications(C/C++):)
hi,
when ever there is need of having same common features among the subclasses of of super class we have to go for AbstractClass, when ever there is no common features for subclasses of super class we have to go for interface
the most real time example of abstract class and interface is bulding a house
1)concrete methods are explained with completed house.
2)abstract classes are explained with completed house but a little bit of work left
3)interfaces are explained with taking a building plan
Well Guys
Don't brush in the air,I mean to know better about two key words start using/studying the codes only then you can have good picture about the strengths between the inheritance and interface.
To feel any loveliness you should start using it. ha ha ha
By
Venky
[QUOTE=nandyalaajay2000;43367]the most real time example of abstract class and interface is bulding a house
1)concrete methods are explained with completed house.
2)abstract classes are explained with completed house but a little bit of work left
3)interfaces are explained with taking a building plan[/QUOTE]
Really liked your "real life" example
When you are making a program for a real time meaning say Building; you create a class say House and then another say Shop both extend Building but you decide to make Building as an abstact class as when you create an object of the building class you don't know which kin of object it will be; will it be house or shop so the program fails and you say ah it is good that this class is made an abstract as we shouldn't create an object of this class.
Interface is a 100 % pure Abstract class means it is a class which is 100 % abstract in nature i.e 100 % unknown what it does.
[QUOTE=Puneet_Khanna;58050]When you are making a program for a real time meaning say Building; you create a class say House and then another say Shop both extend Building but you decide to make Building as an abstact class as when you create an object of the building class you don't know which kin of object it will be; will it be house or shop so the program fails and you say ah it is good that this class is made an abstract as we shouldn't create an object of this class.
Interface is a 100 % pure Abstract class means it is a class which is 100 % abstract in nature i.e 100 % unknown what it does.[/QUOTE]
ok, If telephone is a class then what is a interface in it??? This ques was asked in wipro
[QUOTE=asif.shaik;59429]ok, If telephone is a class then what is a interface in it??? This ques was asked in wipro[/QUOTE]
Well the question asked to you was no related to Abstract Vs interface.
Its say wat kinda inteface(methods) you will have if you have a class called TELEPHONE.
Ans Might be:
1.PickUpCall()
2.dropCall()
3.rejectCall()
4.dialNumber()
etc..
Hope this cleares :)
[QUOTE=asif.shaik;59429]ok, If telephone is a class then what is a interface in it??? This ques was asked in wipro[/QUOTE]
If telephone is a class then its interface can be Talk. this Talk interface can b implemented by Human class as well as Telephone class.:cool: