"Hello, Amigo! I was going to help you with your tasks today. But I'm too tired. And I still have a lot to do this evening: have a beer and play poker with my friends. So, good luck, buddy! Tackle these tasks."
just leaving my "footprint" to say "hey, there are peeps who are still working through these things." (last comment was from June 2020 :) These tasks are not too hard, but re-enforcing important concepts. kinda makes me wonder when CG is going to crank things up hard again! Happy coding! :)
I'm managing to work through all these abstract and interface problems, but I have no idea how it works.
Can anybody suggest good reference (books, articles) to understand this?
http://www.dblab.ntua.gr/~gtsat/collection/Java%20books/Bruce.Eckel.Thinking.In.Java.4th.Edition.Dec.2007.eBook-BBL.pdf
This book was written in 2006, so it only covers up to java 1.5/6. Bruce Eckel does a good job of ensuring every reader is able to understand the concepts. I have about 10 different core Java books and this one is my go to for when I am confused about a topic. The link above is to a pdf of the book. I would recommend purchasing the book so you can sit down and read when your not at your computer and using the pdf as a reference.(After all learning to programming is like learning a foreign language, immerse yourself in the language every chance you get!)
I'm in the same situation, but here's my thinking: maybe the information is too new, and we know it, it just hasn't settled in yet.
So maybe that is why we can work through the exercises but do no know how it works?
I noted and learnt something very interesting in the last example. We want to use the getName method. But its in the abstract class Fox, which cannot be instantiated. Instead we created a BigFoxclass that inherits properties of the FoxClass. In main, we declared a Fox object but instantiate it with the child class BigFoxClass, so that we can use it to access the get name method which it inherits from its abstract parent class
The BigFox inherits Fox and Fox implements Animal getColor() (note, it reaches to the interface, but does not implement its method!). So, Fox doesn't implement Animal's getColor() directly, but in this case, BigFox does it.
So the Fox remains abstract while having Animal's getColor() unimplemented and leaving for down the road to a next class to implement it :)
The getColor() method is implemented by BigFox.
static keyword is used to declare a variable, method or class "shared" it means all the objects have only one copy of that thing. static class is used inside the other class to separate it from that class so that the it does not belong to the objects of the class containing the static class.
GO TO FULL VERSION