• 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

Questions In kathy/Bert book

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.On page 134 Q.2 it says given a method in a protected class?
I am thinking there is no protected class,is that a printing mistake or am I missing anything.
2.Q.5 on page 136 according to book, answer is E.I thought it is D.(I thought number 5 is not a valid declaration)
Is a method is considered as valid method declaration even if there are no curly braces(and not abstract)?
3.On page 140 I felt the option B is little ambiguous,I think it should say
The class must contain a method called public void run() from which all code for that thread will be initiated.
Any kind of help will be greatly appreciated.
Archana
 
Ranch Hand
Posts: 366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Archana,
Please refer to errata for the book
Sri
 
Archana Annamaneni
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You Sri.
My 2 and 3 points are not on the errata, could anybody please explain those two.
-Archana
 
Sridhar Srikanthan
Ranch Hand
Posts: 366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Archana,

2.Q.5 on page 136 according to book, answer is E.I thought it is D.(I thought number 5 is not a valid declaration)
Is a method is considered as valid method declaration even if there are no curly braces(and not abstract)?


I think
private native void m1(); is a valid declaration.
The point you raised is exactly why this bit is given in the question. I faced a similar question on the exam.
JLS 8.4.3.4

A method that is native is implemented in platform-dependent code, typically written in another programming language such as C, C++, FORTRAN, or assembly language. The body of a native method is given as a semicolon only, indicating that the implementation is omitted, instead of a block.



JLS 8.4.5

A compile-time error occurs if a method declaration is either abstract or native and has a block for its body. A compile-time error occurs if a method declaration is neither abstract nor native and has a semicolon for its body.


Regarding the 3rd question, i think thats right too.
What is your exact question about the third one?
Hope this helps
Sri
[ February 14, 2003: Message edited by: Sri Sri ]
 
Archana Annamaneni
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you sri , i really didn't know that native methods end in a semicolon.
My third question is , the option B looks correct but it says a method called run()instead of saying public void run()(The definition looks correct but it didn't specify the correct signature of the method).
So I am confused whether I should choose that as a correct answer or not if it is given in the exam.
I hope I explained my doubt clearly.
Sri I have another question,right now I am preparing kathy/Bert book,do you think i should go through the JLS before I go to exam?
-Archana
 
Sridhar Srikanthan
Ranch Hand
Posts: 366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Archana Annamaneni:
Thank you sri , i really didn't know that native methods end in a semicolon.
My third question is , the option B looks correct but it says a method called run()instead of saying public void run()(The definition looks correct but it didn't specify the correct signature of the method).
So I am confused whether I should choose that as a correct answer or not if it is given in the exam.
I hope I explained my doubt clearly.
Sri I have another question,right now I am preparing kathy/Bert book,do you think i should go through the JLS before I go to exam?
-Archana



Archana,
I do agree that the answer option is a bit vague, but of the given options, it seems to fit the bill. But it is lot more clear on the exam. They take a lot of care in framing the questions.
All you have to remember is
start() method creates a call stack for the thread and moves it into *runnable* state.
run() method actually does the *actual job* which is expected to be done by the thread.
And about the book vs JLS,
In most aspects , the book was more than enough for me added with Dan's explantion of concepts in his topic exams. However, if you have any further doubts about any concepts, the first thing is to refer JLS and try it out.
At the risk of being cliched, I want to say that referrring to JLS is the best way to learn.
Hope this helps
Good luck
Sridhar
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Archana -
Thanks for your questions! We will try to answer as many of the JavaRanch posts as we can, but we are under a tight deadline to finish our next Java book.
We love it when someone jumps in and answers these questions, AND we really want to find all of the problems in the book that we can! So, if anyone asks a question on this forum and it seems to be a real problem in the book, please send us an email !
Hmmm... let me try this again... we might not always log in to JavaRanch and keep track of every thread, so when it turns out that there is a real problem with the book, PLEASE send us an email. (If you're into this kind of thing, we give credit to everyone who spots a problem in the book).
This way we won't miss anything, and we'll have the best possible book!
Thanks !
Bert and Kathy
 
Archana Annamaneni
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you sri , I got it.
Thanks for your questions! We will try to answer as many of the JavaRanch posts as we can, but we are under a tight deadline to finish our next Java book.
We love it when someone jumps in and answers these questions, AND we really want to find all of the problems in the book that we can! So, if anyone asks a question on this forum and it seems to be a real problem in the book, please send us an email !
Sure Bert, we wil definitely let you know, if there is something really wrong.
I really love your book, I will allways try to contribute whatever I can to improve the book.
-Archana
 
No thanks. We have all the government we need. This tiny ad would like you to leave now:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic