wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes two questions from K&B Book, SELF-TESTS, Chapter 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "two questions from K&B Book, SELF-TESTS, Chapter 2" Watch "two questions from K&B Book, SELF-TESTS, Chapter 2" New topic
Author

two questions from K&B Book, SELF-TESTS, Chapter 2

Vikram Bindal
Greenhorn

Joined: Jul 30, 2004
Posts: 7
Hi all,

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
Chris Allen
Ranch Hand

Joined: Feb 01, 2003
Posts: 127
Originally posted by Vikramaditya Bindal:
Hi all,

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.
Shruthi Molakaseema
Greenhorn

Joined: Jun 10, 2004
Posts: 9
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 ]
Kitty Dayal
Ranch Hand

Joined: Jul 22, 2004
Posts: 89
Hi,


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 ??


The most important thing is to read the question and its options very clearly before makin your choices.( By the way, I too many times dont do that).

But if you read option F it says
You <b>MUST</> have an empty public void method called run() in your class.
Which is not true. You can have an non-empty run() (Which you should) if you want to.

Hope this clear's.
Vikram Bindal
Greenhorn

Joined: Jul 30, 2004
Posts: 7
Yes, indeed that does clear my doubts which I had, THANKS !!

"I think, none of the watches, rollex, omega even come close
to the WATCHES that K&B have in their book"
 
wood burning stoves
 
subject: two questions from K&B Book, SELF-TESTS, Chapter 2