Tuesday, March 6, 2012

Java J2EE Interview Questions Part 2

15. How do we test private methods in JUnit?
- Private methods cannot be directly tested. If required we can use Java Reflection to test private methods.

16. How do we test protected methods?

- Place the test class under the same package as the class under test.

17. How do you invoke Stored Procedure from Hibernate?
- use hibernate 3 annotation as:
@NamedNativeQueries({
    @NamedNativeQuery(
    name = "callStockStoreProcedure",
    query = "CALL GetStocks(:stockCode)",
    resultClass = Stock.class
    )
})

Query query = session.getNamedQuery("callStockStoreProcedure")
    .setParameter("stockCode", "7277");
   
18. How do you manage transaction in Spring using Hibernate?
- Declare HibernateTransactionManager and set dataSource and sessionFactory property
- Create TransactionInterceptor and set transactionManager and transactionAttributes
- Now create ProxyFactoryBean and set the target dao/bo bean and interceptorNames

19. How do you configure connection pooling using JDBC?
-

20. How to create store procedure in oracle?
CREATE OR REPLACE PROCEDURE my_store_procedure
IS
BEGIN
    select * from my_table where uid = n;
END;

21. What is the difference between LinkList and ArrayList?

22. What is the difference between forward and send redirect?

23. What is MVC?




In progress...........

No comments:

Post a Comment