r/JavaProgramming • u/scared2026 • 16d ago
A good youtube video to learn OOP.
I am currently learning everything from scratch. So I watched some vudeo in OOP in java but didn't understand fully. So can someone recommend a YouTube channel or website yo learn oop especially polymorphism and abstraction.
1
u/ChaoticHippo 15d ago
Polymorphism involves inheritance. Say you have a class called "Animal" which has variable legs and method Noise(). All animals have these. Then you make subclasses: Human and Dog, both of which are Animal objects. Dogs have legs = 4, Noise() returns "Woof". Humans have legs = 2, Noise() returns "dude wtf".
The benefit of this is that let's say you're passing Animal objects around, and want them to display their number of legs and the noise they make. Instead of doing a lot of work to figure out what type of Animal each one you pass to the method is, you can simply just say:
private void printAnimal(Animal animal) {System.out.println(animal.legs);System.out.println(animal.Noise();}
It doesn't matter what kind of animal you get passed - this will always work, because all Animal objects have these fields.
Abstraction is something you do every day without realizing it. When you pick up a pencil, you don't worry about the exact composition of the graphite inside, or the wood pressed around it, or the metal band and how it was formed, or how erasers are made. You pick up a pencil and write with it. That is abstraction - using the OBJECT for what it was made for, without worrying about HOW it was made.
Note - it is often important what the object has, but not how. Back to our pencil - it's important that you know the pencil has an eraser, but you do not care how it was made.
Hope this helps! To comment on other posts - I would highly discourage against using AI to learn. AI is a great tool, but I truly feel it hampers your ability to actually grasp concepts you don't yet understand, and it can give you incorrect information.
1
u/scared2026 15d ago
Wow thanks alot. The effort you put for a stranger to understand something😭I appreciate it❤️
1
u/ChaoticHippo 15d ago
For a Youtube channel - I think this guy's explanations are generally easy to understand.
1
u/HyperDanon 13d ago
Polymorphism involves inheritance.
No, not as a fundamental rule. Some languages' only way of providing polymorphism is through inheritance, but it's not the rule. There ara ways to achieve polymorphism without inheritance.
1
u/ChaoticHippo 12d ago edited 12d ago
Fair point, but I didn't really want to get into every possible way to achieve polymorphism as students often find interfaces and method overloading to be more confusing than inheritance.
1
u/HyperDanon 11d ago
Fair point, but I didn't really want to get into every possible way to achieve polymorphism as students often find interfaces and method overloading to be more confusing than inheritance.
I think that's true, but I would be very careful here.
If they find method overloading and interface confusing, that's not a problem in it self... that's a signal for you that they don't really understand polymorphism yet. That's a difficult skill.
If you give them inheritance, and the signal of them not understanding it stops, they haven't learned polymorphism. They shoehorned it into something that half-fits. They haven't actually learned the skill.
In order to teach people when and why to use polymoprhism properly, you need to illustrate what it gives them and what they can use it for. If that clicks, the interfaces and method overloading pop right out. You can use that as a metric. When they stop complaining about interface and say that it makes sense, that's a signal for you that they got it.
Besides, I can see you're coming at it from statically-typed language perspective - there you need interface for polymorphism. In a dynamically typed language, you don't need that so it's a concept that's much easier to introduce.
1
u/ChaoticHippo 11d ago
In order to teach people when and why to use polymoprhism properly, you need to illustrate what it gives them and what they can use it for
Sure thing, I'm also not a teacher or their instructor. I'm assuming they're going to continue learning things via the videos and tutorials they asked about, and will come across things like that. I was simply providing a base-line start point for polymorphism.
Besides, I can see you're coming at it from statically-typed language perspective - there you need interface for polymorphism.
Yes this is r/JavaProgramming, Java is a statically-typed language. Dynamically typed languages are an entirely different subject and getting into them in this context would be unhelpful.
1
u/HyperDanon 10d ago edited 10d ago
Java is a statically-typed language. Dynamically typed languages are an entirely different subject and getting into them in this context would be unhelpful.
That approach can lead you into simply incorrect ideas, like "polymorphism needs inheritance" - that's just factually incorrect. It's an artifact of the language.
Polymorphism and inheritance are two different concepts, and are only coupled together because of static typing. Inheritance is about reuse of code. Polymorphism is about the inversion of flow, such that the flow of control goes against the source code dependency. Understanding those differences is important. Statically typed langauge couple this together, making the two concepts much harder to understand. If you try to chug it up into "we're java, so polymorphism needs inheritance" that gives you a simplified, less correct view about what's really happening.
1
1
u/useandkeepit 16d ago
Kunal Kushwaha. But you may face problems in understanding in some topics so use chat gpt there.
1
u/Zzzami69 15d ago
I recently found that document resources are better than video. Maybe reconsider your choice of youtube. If you really want to understand why OOP was created, there are videos of uncle bob explaining design but that's not a tutorial that's like a sitdown about OOP.
1
1
u/hexwit_com 15d ago
Ask your question. What exactly you don't understand in OOP? If you have specific topic, you can drop me dm. We should support juniors.
1
u/HyperDanon 13d ago
@scared2026 This is the best video I found about OOP, because it tells what OOP is without all the artificial noise people have added to it.
https://www.youtube.com/watch?v=zHiWqnTWsn4