Friday 19 June 2015

Java Real time Interview Questions in my Experience?

1. Interview Questions:

         1. Why do you want to work in this industry / company?
2.    Which location do you want to work in and why?
3.    Describe a problem you faced and how you deal with it
4.    What are the types of class loaders in Java.
5.    Write your own ArrayList in Java ?
6.    How to read and write image from a file ?
7.    What is difference between static and init block in java.
8.    How ConcurrentMap works?
9.    Can a static block throw exception?
10. What is difference between iterator access and index access?
11. Why character array is better than string for storing password in java?
12. what is daemon thread in java
13. What is Java Reflection API?
14. What is the difference between Serializable and Externalizable interfaces?
15. Explain the difference between Shallow Copy and Deep Copy.

2. Interview Questions:

1. Tell me about your self ?
2.  What will you do to your company?
3.  What is transient variable ?
4.  Write the code to initialize the inner class members.
5.  How to retrieve the elements from the collection write the code
6.  static and instance variables and methods
7.  dynamic loading and static loading
8.  What type of loading is class.forname() ? 
9.  hibernate 3 best benefits
10. how to find the class name
11.I have 100 tables and fields ....I want to find one table name and fields names in hibernate
12. What is Synchronization ?
13. most commonly used classes in collections.

3. Interview Questions:

1. What is Difference between interface and abstract class ?
2.    Can u write final method in interface ? No
3.    Can u write final method in abstract class ? Yes, Only for non-abstract methods
4.    What is Difference between iterator and list iterator?
5.    Difference between synchronized block and synchronized method ?
6.    Difference between string and string buffer class ?
7.    How to get the session object in JSP ?
8.    How to get the session factory obj in hibernate ?
9.    How to handle the runtime exception in jsp?
10. Difference between method overloading and overriding ?
11. Difference between java.util.date and java.sql.date ?
12. I have 1 to 100 elements in array unordered,one element missed find that one?
13. Difference between equals() and hashcode()?
14. What is comparator ?
15. We have equals() to compare two methods then why comparator again ?
16. What is auto wiring in spring ?
17. We can get the container obj through Beanfactory and Application context what is the difference in both ?
18. What is the Difference between get() and load() in hibernate ?
19. Difference between page and pagecontext in jsp ?
20. What is application in jsp ?
21. How to create the user-defined immutable class ?

4. Interview Questions :

         1. Tell me about yourself?
2.    What is the difference between String and StringBuffer?
3.    What do you mean by immutable?
4.    Can you explain the same with an example?
5.    How do you compare objects of String and StringBuffer?
6.    Can you list few methods that are available at Object class level?
7.    Why is thread methods like notify and notifyAll is defined at Object level?
8.    What are run time exceptions?
9.    What is Marker interface?
10. What is the serialization?
11. How to make a class or a bean serializable?
12. If two Interfaces have same Method, how to handle that Method in a Class implementing these two Interfaces?
13. Explain Servlet Life cycle ?
14. What is the difference between GET and POST?
15. What is SingleThreadModel?
16. What is the difference between ServletContext and ServletConfig parameter?
17. How can we know that a session  has already existed or not ?
        5.Interview Questions:
1. Tell me about your self ?
2. What are the types of class loaders in Java.
3.  write your own ArrayList in Java ?
4.  How to read and write image from a file ?
5.  What is difference between static and init block in java.
6.  How ConcurrentMap works?
7.  Can a static block throw exception?
8.  What is difference between iterator access and index access?
9.  Why character array is better than string for storing password in java?
10.  What is the difference between Serializable and Externalizable interfaces
11.  Which Interface is used to make duplicate of Objects ? Ans: cloneable
12.  What are some advantages and disadvantages of Java Sockets?
13.  When can an object reference be cast to an interface reference?
14.  How does Java allocate stack and heap memory ?
15.  What is memory leak in java ?
16.  Can we throw exception from finally block in JAVA ?
17.  How does Java handle integer overflows and underflows?
18.  Tell me  difference between Stringbuffer and stringbuilder ?
19.  What is casting?
20.  what is new in JSP?
21.  What do you mean by Java Reflection ?
22.  Why does the InputStreamReader class has a read() ?
23.  Describe a problem you faced and how you dealt with it
6.Interview Questions:

1. Tell me about your self?
2. Difference between string s= new string (); and string s = "abv" ?
3. Whats wrapper class ?
4. What is the difference between abstract and interfaces ?
5. What's use of Ajax?
6. What parsers are supported in Ajax?
7. How can execute the prepared statement is executed in more than one in  application? Where the prepared statement object is created either DB or application
8. What situation validation framework is applied in struts framework.
9. What is difference between the validation.xml and validation rules.xml.
10. What's difference between the HTML and DHTML ?
11. What happens when the notify() method is called ?
 7. Interview Questions: 

1. What are differences b/w concrete,abstract classes and interface & they are given?                                                                              
Concrete class:   A class of  only Concrete methods is called Concrete Class. For this, object instantiation is possible directly. A class can extends one class and implements many interfaces.
               Abstract class:
                      Interface:
*A class of only Concrete or only Abstract or both.

*Any java class can extend only one abstract class.

*It won’t force the programmer to implement/override all its methods.

*It takes less execution time than interface.

*   It allows constructor.

This class can’t be instantiated directly.
                      
 A class must be abstract when it consist at least one abstract method.
                     
It gives less scope than an Interface.

It allows both variable & constants declaration.


It allows methods definitions or declarations whenever we want.

It gives reusability hence it can’t be declared as “final”.
 only abstract methods.
                

A class can implements any no. of  interfaces
(this gives multiple interface inheritance )

It forces the programmer to implement all its methods

Interface takes more execution time due to its complex hierarchy.
*   It won’t allow any constructor.

It can’t be instantiated but it can refer to its subclass objects.
It gives more scope than an abstract class.
                
By default, methods  are public  abstract   variables are public static final.

               
It allows  methods declarations whenever we want . But it involves complexity.
              
Since they give reusability hence they must not be declared as “final”.

2) Can you create a userdefined immutable class like String?
 Yes, by making the class as final and its data members as private, final.

3) Name some struts supplied tags?
§  struts_html.tld
§  struts_bean.tld
§  struts_logic.tld
§  struts_nested.tld
§  struts_template.tld
§  struts_tiles.tld.
 4) How to retieve the objects from an ArrayList?
 

 List list=new ArrayList();        
 list.add(“element1”);                 

 list.add(“element2”);
 list.add(“element3”);          

 Iterator iterator=list.iterator();    
 while(iterator.hasNext()){
  String str=(String)itr.next();       
  s.o.p(string);           
  } 

List<String> list=new ArrayList<String>();  
 list.add(“element1”);                 
 list.add(“element2”);
 list.add(“element3”); 

for(String str:list) {  
s.o.p(str);

                                   
5)  What are versions of your current project technologies?
Java 5.0; Servlets 2.4, Jsp 2.0; struts 1.3.4 ; spring 2.0; Hibernate 3.2, Oracle 9i. weblogic 8.5.
 

6) What is “Quality”?
 It is a Measure of excellence.state of being free from defects, deficiencies, and significant  variations.
 A product or service that bears its ability to satisfy stated or implied needs."
 

7) Can I take a class as “private”?
Yes, but it is declare to inner class, not to outer class.If we are declaring "private" to outer class nothing can be accessed from that outer class to inner class.
 

8)  How can you clone an object?
 A a1=new ();
 B  a11=a1.clone();
 

9) What methods are there in Cloneable interface?
Since Cloneable is a Marker/Tag interface, no methods present.When a class implements this interface that class obtains some special behavior and that will be realized by the JVM.
 

10)  What is the struts latest version?
Struts 2.0
 

11) How are you using “Statement” like interface methods even without knowing their implementations classes in JDBC?

12) Which JSP methods can be overridden?
jspInit() & jspDestroy().
 

13) Explain the JSP life-cycle methods?
§  Page translation: The page is parsed & a Java file containing the corresponding servlet is created
§  Page compilation:   The Java file is compiled.
§  Load class: The compiled class is loaded.
§  Create instance: An instance of the servlet is created.
§  Call jspInit():This method is called before any other ethod to allow initialization.
§  Call _jspService():This method is called for each request. (can’t be overridden)
§  Call jspDestroy(): The container calls this when it decides take the instance out of service.It is the last method called n the servlet instance.    

    8. Interview Questions
:
            1. Tell me about your self?
2.    Explain your current project ?
3.    What is static in java?
4.    What is the use of singleton class ?
5.    Oracle Thin Driver comes under which type of Driver ?
6.    Is it possible to write methods in JSP ? If so, how ?
7.    Can u write final method in abstract class ?
8.    Difference between method overloading and overriding ?
9.    What is Difference between interface and abstract class ?
10. How to get the sessionfactory obj in hibernate ?
11. What is the difference between exception and error?
12. Difference between java.util.date and java.sql.date ?
13. What is comparator ?
14. We have equals() to compare two methods then why comparator again ?
15. Which type of EJB can use bean pooling ?
16. How can you call an EJB from a JSP/Servlet ?
17. Who is loading the init() method of servlet? 

     9. Interview Questions:
                   1.  Why native methods are used ?
2.    How do you declare a page as Error Page. What tag you include in a JSP page so that it goes to specified error page in case of an exception ?
3.    Difference between Include Directive & Include Tag ?
4.    Servlet is a java class. So, can there be a constructor in Servlet class or not ? Why ?
5.    What's the difference between forward & include tags? What URL (absolute or relative) is used in RequestDispatcher forward?
6.    Is it possible to write methods in JSP ? If so, how ?
7.    Difference between JSP & Servlets ?
8.    Difference between Hashtable & HashMap ?
9.    By default, Hashtable is unordered. Then, how can you retrieve Hashtable elements in the same order as they are put inside?
10. Which type of EJB can use bean pooling ?
11. How can you call an EJB from a JSP/Servlet ?
12. How to configure Data Source in WebSphere server ?
13. Oracle Thin Driver comes under which type of Driver ?

    10.Interview Questions
:
         1. Tell me about your self? 
2.    What is the difference between an Interface and an Abstract class? 
3.    Can abstract class have constructors ?
4.    How many ways we can call garbage collector ?
5.    What is use of load on startup tag ?
6.    What is the difference between notify() and notifyAll() methods ?
7.    Why the notify and notifyAll() methods included in Object class ?
8.    What is the difference between HashMap and TreeMap ?
9.    What is the use of hibernate ?
10. What are the types of cache levels available in Hibernate ? How to configure ?
11. What is the difference between Servlet and filters ? 
12. What is SingleThreadModel interface ?
13. What are the implicit objects available in JSP ?
14. How does JSP handle run-time exceptions?  
15. What is the difference between update and merge in hibernate ?

16. Write a query to retrieve highest salary by dept id ?

1 comment: