Tuesday, April 6, 2010

Some interesting concepts

Concepts of a person give a good insight on how person thinks and would be able to think when a problem domain is in front of them. So, often interviews involving entry level include questions comprising of basic concepts. Although, interviewer doesn't except bookish answers he also doesn't except below too. Or do they ?

Some of the questions in one such interview where I was involved and almost started to wonder do I know what I know is correct.


....
....

Q: What is the purpose of finalize method ?
A: Finalize is one of the methods in object class. Flinalize method tells us whether GC (garbage collecter) is running or not.

Whoa !!! interesting ... just wondering why do i need to know the status of GC anyway.

....
....

Q: As you said wait / notify are methods of object. Can I call these methods anywhere I wish or there is any restriction ?
A: They can be called in synchronized block. .... and method also.

...

Q: So can we have static synchronized method ?
A: Let me think !!!! After some thinking ...... I don't think so. Static method is associated with class not instance. Since we don't have an object to have lock on, it is not possible.

Ohhh !!!! Answer with logical explaintion.

....
....

And then best of all 

Q: What are prepared statements ?
A: They are pre-compiled statements, good for performance.

Yeah !!! This fellow knows what prepared statements are. I also thought so. Keep reading.

Q:So why are such statements called pre-compiled statements ?
A: Because the are compiled only once. Suppose we want to execute a query "select * from employee where employeeId=?" Such queries where ? are there and we set values before executing are prepared statements.

Q:Okay, we have ? in query, so our statement would be prepared statement ?
A: Yes

Q: What do you mean with compiling ... in pre-compiler statement ?
A: When we compile java class, query written in java also gets compiled. So we also call it pre-compiled statement. 

Ohh no !!! he did it again another concept.

Q: Oh.. so If we want to fetch all employees from employee table "select * from employee" and compile java class. My query would get compiled first. So I would have pre-complied statement ?
A: Yes 

Whoa !!!! 

....
...

I hope after reading this, you found some thing not to learn from.

1 comment:

  1. I wonder whether someone would ever talk about binaryfied statements :P

    ReplyDelete