Can anybody give a good URL to overriding/inheriting tutorial? I'm not looking for basis, I need full explanation for questions like: "Which method from which class will be invoked?", regarding from: - overriden/overriding methods' modifiers; - methods' invocation place (for example, a call from another method belonging to the same/ inheriting class); - object's run-time and compile-time class. Thanx in advance.
:-) Seriously, this book will teach you everything you need.
In a nutshell, here are the rules for overriding:
The overriding method: - cannot have a more restrictive access modifier than the parent - argument list must match exactly - return type must match exactly - access level can be less restritive - ex. parent method is protected, child can be public - cannot throw new or broader checked exceptions - can throw narrower or fewer checked exceptions - ex. parent throws IOException, child can throw FileNotFoundException or nothing but can't throw Exception - cannot override a method marked final - cannot override a method that can't be inherited due to access restriction - ex. private method cannot ever be overriden
Also, the method invoked is determined at run-time based on the actual object on the heap, regardless of reference variable type.
P.S. Wish me luck, I'm taking the test on Wednesday!
posted 15 years ago
I haven't read Kathy's book, but I did participate in the technical review of the exams contained at the end of each chapter. After the technical review of K&B, I removed a lot of questions from my mock exam that were either too difficult or too far beyond the scope of the real exam. What is left are questions that are only a little more difficult than those on the real exam. The score that a person gets on the real exam is typically higher than their score on my exam.
My book is completely different from K&B. A person that has never read a Java fundamentals textbook could pick up the K&B SCJP study guide and have no trouble understanding it. My book is organized differently. The chapters in my book are intended to provide only a short preview of the material on the exam contained in the chapter. The detailed explanations of the topics are provided as explanations for questions. The organization of my book allows the reader to easily avoid reading material that the reader does not need.
The organization of my book allows it to work very well as a workbook to accompany any other study guide such as K&B. While a typical study guide has long chapters and short exams, my book has very short chapters but very long exams with detailed answer explanations.
My book can also be used by those that have already read a Java fundamentals textbook and are not interested in rereading the same material in a study guide. Instead, an experience Java programmer might prefer to jump right into a mock exam that will allow the person to identify the topics that they need to review, and the review of those topic is provided by the detailed answer explanations that follow the exam. You could say that my book is like a study guide turned inside out.
I receive a lot of email from people that prepared for the exam by using nothing more than my exams and the detailed answer explanations. Of course, I also receive a lot of email from people that used my exams and detailed answer explanations as a workbook along with a study guide such as K&B.
Michal, I hope your still here, because I want to give you another URL. Please see Section 8.4.6 of the Java Language Specification. The JLS will tell you everything that you ever wanted to know about inheritance. K&B was not published until after I completed the exam, so the JLS was one of my primary sources of exam preparation material. Of course, the JLS does not contain mock exams, so I created my own. Those exams have been available on-line for a couple years. Now they are available in my book along with some additional material that is not available on my web site. If you would like to buy a book that contains material that has been reviewed by the entire world for about two years, then my book is for you!
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
permaculture is giving a gift to your future self. After reading this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps