Skip to main content

Interview Questions Updated 10/7/2015

Here are couple of questions based on my interview experience, Please update/Comment.

1. Why string is immutable in java ?


2. What is  Serializable and Externalizable in java ?
     How to customize serialization process ? 
3. Can we serialize static variables of class ?

4. Static variables are associated with class or Object ?

5. At which level serialization happens object or class ?

6.  Can transient variable be serialized explain ?

7.  how to make any class immutable in java ?

8. Difference between String Builder and String Buffer ??

9. How to revers any string example String test=new String("I am ashish") output should be "ashish am i" ?

10. write down sql query for finding out name of employee and there manager .

Employee Table with 3 column 

E_Name E_Name Manager_ID

Where Manager_ID is the subset of E_ID

11. what is instance variable, static variable in java ?




Adding few more questions -


1. why hashtable allow null key and values not hashmap 

2. what is the significance of thread.start() and thread.run() method ..

3. How hashmap work while passing key and value as a class

Employee class and Salary class

Implement in such a way to get the salary corresponding to each employee.

4. equals and hashcode logic

5. Employee emp1=new Employee("ashish");
Employee emp2=new Employee("ashish"); 

emp1.equals(emp2) // what will be the output

6. If we have list of employees ..how we sort based on emp_name and emp_id?

7. 

Class A
{

method m1()
}

class B
{

}

main()
{

A a=new B()

a.m1 // what will happen here
}


Class A
{
}
Class B
{

method m1()
}

main()
{

A a=new B()
a.m1()// what will happen here

8.

String str1="ashish";
String str2=new String("ashish");

if(str1.equals(str2)) // output

if(str1==str2) // output

Explain the output ?

9. Design pattern singleton,adaptor,facade,decorator patter ?

Comments