Tuesday, January 12, 2010

Interview Questions

Interview Questions

I have been on interview mode for past few weeks and attended some interviews. Here are some sample question asked by interviewers. I am posting only the questions, Google for best answers.

  1. Can I pass HTTPSession object to EJB?

  2. Explain some J2EE design patterns

  3. In struts, can we add some preprocessing code before action gets executed? (Request processor)

  4. Can I print a string in a program without using main method? (static block)

  5. How do you set up cluster in Websphere

  6. Can you explain struts life cycle?

  7. Are you exposed to Ajile methodology? Can you explain the cycle

  8. Do you have any experiences with Ajax

  9. Can you explain the life cycle of session beans?

  10. I have two tables with 10 and 2 rows, How many rows will select * from table1, tabl2 fetch
    (10?or 12 rows – hint cartesian – 10*2 rows)

  11. What is the difference between HashTable vs HashMap

  12. What is the difference between Vector and Arraylist

  13. What is synchronized block and where do you use it

  14. What is the difference between Union vs Join
    Answer: For Union the column name and datatypes must match. Union eliminates duplicate row

  15. What is the difference between interface and abstract

  16. difference between java & j2ee

  17. explain value object pattern & where do you use?

  18. Difference between ibatis & hibernate

  19. Difference between servlets and JSP


SQL Notes

SQL Notes


True or false: You must also use theGROUP BYclause when using theHAVINGclause.

False – having clause can be used without group by

Group by vs Order by

In group by all non aggregate columns must be selected.

Group by is used to group identical data

order by is designed merely to put a data in a specific order.

It is generally not necessary unless using aggregate functions like sum, avg,count.

SELECT COUNT(EMPLOYEE_ID), SALARY FROM EMPLOYEE_PAY_TBL;

The result will display the first salary along with count.

AVGfunction does not consider null values

INSTR

The INSTR function is used to search a string of characters for a specific set of characters

and report the position of those characters. The syntax is as follows:

INSTR( COLUMN NAME, ‘ SET’,

[ START POSITION[ , OCCURRENCE] ]);

LTRIM(CHARACTER STRING[ ,set’])

DECODE(COLUMN NAME,SEARCH1’,RETURN1’,[SEARCH2’,RETURN2’,DEFAULTVALUE’])

Coalesce:Function to check null in specified order and return not null values if any found

coalesce(column1,column2,column3... so on)

ASCII – returns acii set

Conversion functions

TO_NUMBER

CAST – Operator to convert datatypes into other data types.

Convert date to string

to_char(date_column,'month yy dd')

Natural join vs Inner join

Natural join – no need to specify column name

Inner join – column name in join is required

Not equal join,

If table a has 6 rows and table b has 8 rows then non equal join produces

6*(8-1) rows since it excludes the current row in the join instead of 6*8 rows

Subqueries

1.Order by clause cannot be used in subquery where as group by can be used to get achieve the same.

2. Between operator cannot be used with subquery

Correlated subquery – a subquery that depends on information specified from main query

Union vs Union ALL – former eliminates duplicate, later includes it.

Oracle – select random rows – use sample(10) where 10 is 10% of total rows.

Views – insert/update – the underlying data cannot involve joins or group by clause or union statement.

Create view cannot have order by clause – use group by instead.