• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Lock Doubt

 
Venkat01
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody,
Anyone please clarify the following.
3.Which of the following statements about threading are true?
A)You can obtain mutually exclusive lock on methods that
extends thread or implements runnable.
B)You can only obtain mutually exclusive lock on methods that
extends thread or implements runnable
C)You can obtain lock on any of methods. --true
D)You can obtain mutually exclusive lock on any of methods.
suprising, nothing about synchronised is there in the options.
Another silly question, but i am confused.
4.Which cannot be used in declaring and initializing an automatic (method call)
variable?
A. Final
B. Public --false
C. Constants of non-primitive type
D. Inner class from other scopes
E. Initialized arrays(such as "{Hello", "Goodbye"})
Thanking all.
 
Harry Chawla
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sheriffs and Ranch hands
can somebody pls answer to this.
Thanks.

 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Venkat,
I am assuming the question #3 is the one right answer (radio-button ) kind of question. Here, you will have to pick the most appropriate answer. I agree the answers confuse you, but remember they are also making sure you read all the answers first. Also, I felt the answer D is incomplete( and syntactically incorrect ! ). What you have chosen, ie., C seems to be the right answer. What is being examined here is not how you can synchronize a method, but what you can synchronize. That's why there is no mention of the synchronized keyword.
For question 4, again what you have chosen is the right answer. However, the question itself, IMO is incorrectly worded. Automatic variables are those which are declared within the scope of a method, but the question is using the word method call ... for some reason that I can't comprehend.
Hope this helps,
Ajith
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic