Prognoz Technologies Pvt. Ltd.
Java Interview Questions (Typical)
• What is difference between String, StringBuffer and StringBuilder? When to
use them?
• Why main () in java is declared as public static void main? What if the main
method is declared as private? Can you access a non-static variable in the
static context?
• Which one will you use Statement or PreparedStatement? Or which one to
use when (Statement/PreparedStatement)? Compare PreparedStatement vs
Statement.
• What are the alternatives to Serialization? If Serialization is not used, is it
possible to persist or transfer an object using any other approach?
• Why is a constructor needed in a servlet even if we use the init method?
• What will happen if you put return statement or System.exit () on try or catch
block? Will finally block execute?
• What will happen if we put a key object in a HashMap which is already there?
• How do you ensure that N thread can access N resources without deadlock?
• What is difference between CyclicBarrier and CountDownLatch in Java?
• When Singleton doesn't remain Singleton in Java?
• Why is (Integer) 1 == (Integer) 1 but (Integer) 222! = (Integer) 222 and which
command arguments change this?
• Is it possible for equals () to return false, even if contents of two Objects are
same?
Prognoz Technologies Pvt. Ltd.
S-186 & 184A, Haware Fantasia Business Park, Plot No. 47, Sector 30A, Vashi, Navi Mumbai-400703, India
Tel: 022-27814262 , 8454071212 | E-mail: | Website: www.prognoztech.com
Java Interview Questions (Typical)
• What is difference between String, StringBuffer and StringBuilder? When to
use them?
• Why main () in java is declared as public static void main? What if the main
method is declared as private? Can you access a non-static variable in the
static context?
• Which one will you use Statement or PreparedStatement? Or which one to
use when (Statement/PreparedStatement)? Compare PreparedStatement vs
Statement.
• What are the alternatives to Serialization? If Serialization is not used, is it
possible to persist or transfer an object using any other approach?
• Why is a constructor needed in a servlet even if we use the init method?
• What will happen if you put return statement or System.exit () on try or catch
block? Will finally block execute?
• What will happen if we put a key object in a HashMap which is already there?
• How do you ensure that N thread can access N resources without deadlock?
• What is difference between CyclicBarrier and CountDownLatch in Java?
• When Singleton doesn't remain Singleton in Java?
• Why is (Integer) 1 == (Integer) 1 but (Integer) 222! = (Integer) 222 and which
command arguments change this?
• Is it possible for equals () to return false, even if contents of two Objects are
same?
Prognoz Technologies Pvt. Ltd.
S-186 & 184A, Haware Fantasia Business Park, Plot No. 47, Sector 30A, Vashi, Navi Mumbai-400703, India
Tel: 022-27814262 , 8454071212 | E-mail: | Website: www.prognoztech.com