+ 1

"To use an abstract class, you have to inherit it from another class"then in this sentences abstract class is superclass or not?

20th Dec 2017, 3:37 AM
Jayshri Patil
Jayshri Patil - avatar
5 Réponses
+ 2
Abstract concept is like: You have a list of toys and you have a function that returns True if a string "car" is in the list, and another function that does the same with a "balloon" string. The best option is to create an "abstract" function that does the same than others, but you pass the string of you want to search as a parameter. The concept is Functional Abstraction. So... If we speak of classes, abstract class is not the superclass, but this way to code is best option (in my opinion). You can have a Toy class, and then you create a Car and Balloon classes that inherit from Toy. Or maybe you just specifie the name of the object Toy: "Car" and "Balloon" (but it's bad for this example... A balloon can't ride or to have wherls :P) I hope this explanation helps you, and sorry for my english jajajaj
20th Dec 2017, 4:30 AM
Sebastián Zapata
Sebastián Zapata - avatar
0
plz explain. it's explain have to inherit it then those class present that is either subclass or superclass
20th Dec 2017, 3:40 AM
Jayshri Patil
Jayshri Patil - avatar
0
i don't understand this concept...u r r8 but u say, toy class inherit car and balloon then in coding how to write code explain ...you use the keyword extends to inherit class..then where u write abstract keyword.
20th Dec 2017, 5:39 AM
Jayshri Patil
Jayshri Patil - avatar
0
For classes this example was bad but, maybe can work. There is no keyword "abstract" or something like that, it's just a concept (if u weren't asking that, sorry I have to work in my english jeje). Imagine you need to create a MP3 and MP4 classes, they have functions (methods on coding) like play music, record audio, turn on, turn off, etc... Instead you define the same methods for them, it's better to create a superclass (both of them will inherit from this) that has that functions. This is abstraction (and a great way to code optimizing)
20th Dec 2017, 7:31 AM
Sebastián Zapata
Sebastián Zapata - avatar
0
kk.still f9..thank you...don't say sorry because i'm doing same..my english communication also not good.
20th Dec 2017, 7:38 AM
Jayshri Patil
Jayshri Patil - avatar