We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>
+ Link For Assignments, GDBs & Online Quizzes Solution
+ Link For Past Papers, Solved MCQs, Short Notes & More
Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion
How to Add New Discussion in Study Group ? Step By Step Guide Click Here.
In programming languages, an abstract class is a generic class (or type of object) used as a basis for creating specific objects that conform to its protocol, or the set of operations it supports. Abstract classes are not instantiated directly.
Abstract classes are useful when creating hierarchies of classes that model reality because they make it possible to specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class (a derived class) is needed.
.+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)
+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)+ Click Here to Search (Looking For something at vustudents.ning.com?) + Click Here To Join (Our facebook study Group)
Very much simple example of abstract class is real life example of Printer, Car.
Printer or Car it self is nothing but you have some abstract definition in mind that something which do like this (print on paper thru some electric/mechenical operation). so anything which has print functionality will call a printer. what the non abstract things of printer are
but Printer is abstract there is nothing in this world called Printer.
Same is Car. car is an abstract idea what the real type u may find is
so car it self is abstract thing. you can say abstraction is a template. anything which will look like that particular template Car will called a Car and anything which will look like the template Printer will call a Printer.
through Abstract classes we achieve Polymorphic behavior means polymorphisom.
which means a functionality behave differently in dfferent classes but in a same hierarchy.
printing is functionalty of Printer
LasterPrinter print differently
ColorPrinter print differently
LaserPrinter print differently
Same accelrate, break, changeGear is functionality of a Car
AutomaticCar does samething differently than ManualCar
so accelrate, break and changeGear are polymorphic function
and the statement i mentioned "in a class hierarchy" means AutomaticCar is in hierarchy of Car and manualCar is also in hierarchy of Car.
but LasterPrinter is not hierarchy of Car class this is in hierarchy of Printer class
let see a another real world example of polymorphic behavior suppose you have open 3 document in MS Word
but there is only one SAVE button above.
this save button has polymorphic behavior because it will work only for that document which is currently open.
when u switch to other document it will start working for that particular document.
so Concluded that abstract class never exist in world while its a template , which class will follow that template will become that class this behavior also calssed IS-A
LaserPrinter IS-A Printer
AutomaticCar IS-A Car
Thanks for reading
please tell about overloading and overriding?