Can you help me explain abstract for java in the simplest way? Until the moment I don't understand it, even though I tried. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you help me explain abstract for java in the simplest way? Until the moment I don't understand it, even though I tried.

19th Jul 2018, 7:40 AM
Ibrahim Kadri
Ibrahim Kadri - avatar
3 Answers
+ 1
Abstract is like a framework of a car or something else that you cannot use it. But other classes that inherited from it will add different wheels and motors to it and then it can run differently. Hope you know what i am saying.
19th Jul 2018, 7:56 AM
LAWArthur
0
An abstract method is a method which is not implemented, such as: public abstract void example(); If someone wants to create an object of the class containing an abstract function, he can't do it directly. He has to extend it to another class where you Override those methods. For my example, I'll use an Interface, a completely abstract class. You have an app where users can purchase stuff. For the paying actions you create a class which handels different ways to pay, like PayPal, with card etc. You could do this with a normal class with a function for every paying method. But there's a problem: What if PayPal changes the way it works? Your method for paying with PayPal would be garbage. Now we get to the Interface. Here, you do not implement the paying functions. You just say: "For every way of paying, that company must inplement that themselves". You just call the functions without knowing how they are implemented, but you can be sure that you can use that funtion savely.
19th Jul 2018, 7:56 AM
Jonas Schröter
Jonas Schröter - avatar
0
23rd Jul 2018, 6:45 AM
Ibrahim Kadri
Ibrahim Kadri - avatar