I am not sure if I am actually allowed to post the question directly from the K&B book here for public viewing. So at this stage, just going to mention, two questions which I had.
Chapter 2, SELF - TESTS, Question 3 Correct Answer accd to the book: A, C, E I choosed A, E and F My reason for selecting F:
Option F states that "If class A was not abstract and method m1( ) on line 2 was implemented, the code would not compile".
If one examines the code snippet given, Then accd to the theory, If a class has a method abstract, then the class should be declared abstract, ELSE ERRORS !!!.
Though, even option C looked right to me, but the question said PICK Only three. Am I CORRECT OR WRONG, if wrong, then can someone please explain me WHY ? thanks :-)
Chapter 2, SELF - TESTS, Question 14 I selected C and F, the book says B and F.
My Reason: I know the "run" method to be used for whenever the Runnable interface is implemented ( "public void run( )" ).. How can ONE FORGET, K&B highlighted this in a very "ATTRACTING MANNER" :-).
But the way the options for the questions were put, It appeared to me, that they were very much precise to as if just run() method or public void run().
I just wanted to ensure, when one see's a question like this, which is the way to go ??
Those were the two questions I had.. Help would be appreciated.
Oh and K&B, I wish you could also write some of the electrical engineering books. I am sure.. I know lot of guys who would have been thankfull to u, including me.. :-) Your BOOK ROCKSSSSSSSSSSSSS
For Question #3, I think the authors are saying that if the method m1() on line 2 was implemented that it infers that the abstract modifier would be removed as well. Thus, the code WOULD compile. Therefore, answer f is false and does not meet the criteria.
For Question #14, I interpreted answer C as saying you can ONLY have a run method that is empty. Obviously, you can put any code you wish into the run method (within reason).
I do agree with you though, the K&B book is excellent. I have read three other Java certifiation books and none came close to the level of detail and ease of reading that this book gives the reader.
The answers which are given in the book are correct.
For Q#3 answer F is not correct If class A was not abstract and method m1() on line 2 was implemented (means remove abstract, semicolon and put curly braces, implementation code in the method) then the code will compile even though the class B is abstract. So, the answer is F is incorrect.
For Q#14 answer are B and F
we always write the code that needs to be run in a thread in a run() method.If u put empty run() method, the thread doesn't do anything. we know that after executing run method the thread will die. I am not sure, but i think we should write some code in the run() method otherwise it will assume abstract.Given that the class implementing Runnable is nonabstract. [ July 31, 2004: Message edited by: Shruthi Molakaseema ]