ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
What are the two ways you can synchronize a block of code?
 Question Submitted By :: Manoj Pandey
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What are the two ways you can synchronize a block of code?
Answer
# 1
There are two ways to syanchronize access to an object 

1st one is using synchronized keyword for example 
	
	Synchronized type methodname(arg-list)
		{
			//synchrinized method body
		}

2nd way s using synchronized block

	synchronized(object)
	{
		//synchronized statement

	}
 
Is This Answer Correct ?    14 Yes 0 No
Vikki
 
  Re: What are the two ways you can synchronize a block of code?
Answer
# 2
bu using thread in your main program
 
Is This Answer Correct ?    1 Yes 7 No
Guest
 
 
 
  Re: What are the two ways you can synchronize a block of code?
Answer
# 3
The way you can synchronize the block is:-

synchronized(dummy object)
	{
		//synchronized statement

	}
In dummy object you can use this or u can create a dummy 
object by using new Keyword.

What answer Vikki is posted as the first one is not the way 
of synchronizing the block but it's a way to synchronizing 
a method.
 
Is This Answer Correct ?    1 Yes 0 No
Ajay Tiwary
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Describe inheritance as applied to java?  4
write a progam hashmap & hashtable? IBM2
How to make class immutable  5
What is the exact difference in between Unicast and Multicast object ? Accenture1
What is OOP? BMC2
10. class Nav{ 11. public enum Direction { NORTH, SOUTH, EAST, WEST } 12. } 13. public class Sprite{ 14. // insert code here 15. } Which code, inserted at line 14, allows the Sprite class to compile? a)Direction d = NORTH; b)Nav.Direction d = NORTH; c)Direction d = Direction.NORTH; d)Nav.Direction d = Nav.Direction.NORTH;  1
Does 'true' and 'false' are keywords?  5
what is meant by serialization?  6
By what default value is an object reference declared as an instance variable? Wipro1
what is an anonymous class? TCS5
System.out.println(101/14) what is the output? a)6 b)14 c)7.14 d)0 Accenture6
Write program to print Hello World and print each character address in that string and print how many times each character is in that string? Ex: H: 0 & 1 e:1 & 1 l :2,3,8 & 3 o:4,6 & 2 w:5 & 1 r: 7 & 1 d 9 & 1 Huawei3
How the elements are organized in GridLayout?  1
types of applets?. TCS3
What is run-time class and system class? what is their purpose?  1
What are concepts of OOPS and how are they implemented in Java? KPIT2
how to call One constructor from another; Innodata-Isogen7
how to connect one jsp page to another jsp page???? Symphony4
Difference between canvas class & graphics class?  1
What is Session and cookies?Explain in detail with an example? CTS2
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com