954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

an interview question

why we can't specify like the following code
synchronized class a
{

--

}

if we want to synchronize a class we need to code like

synchronized(a.class) ?

If any body help me I will be very thankfull to them.

satish.paluvai
Light Poster
45 posts since Mar 2007
Reputation Points: 9
Solved Threads: 1
 

IMO, a class provides a template for the creation of objects. It doesn't make sense to make a class synchronized. You can always make all the methods of a class synchronized if you want or place synchronized blocks inside methods and .

Read this whole thing.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

only correct answer: because the language specification doesn't allow it.
Why it doesn't allow it you should ask the people who invented the language, but better make sure you have a less silly reason for the question than "it was asked during an interview" because they'll be more likely to enter into a debate about the futility of stupid interview questions than language design decisions.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You