• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
 
reply
    Bookmark Topic Watch Topic
  • New Topic