Saturday, January 29, 2011

interview questions

reflections in java
BST
join - outer join
ACID
level of isolation DB provides.
deadlocks, how to avoid them
concurrentmodification exception java - what code will you look at
command to list open files for a process
command to list processes which have opened a specific file
commands related to find and grep

Database Isolation Levels

  • REPEATABLE READ: Protects against Lost Updates, Dirty Reads, Nonrepeatable Reads, and Phantoms
  • READ STABILITY: Protects against Lost Updates, Dirty Reads, and Nonrepeatable Reads. Read stability does not protect against Phantoms.
  • CURSOR STABILITY: Protects against Nonrepeatable Reads and Phantoms. Cursor Stability does not protect against Lost Updates and Dirty Reads.
  • UNCOMMITED READ: Protects against Lost Updates. Uncommitted Read does not protect against Phantoms, Dirty Reads, and Nonrepeatable Reads.

ACID

http://en.wikipedia.org/wiki/ACID

ACID (atomicity, consistency, isolation, durability)

Friday, January 7, 2011

the differences between HashMap and Hashtable?

Answer
Both provide key-value access to data. The Hashtable is one of the original collection classes in Java. HashMap is part of the new Collections Framework, added with Java 2, v1.2.

The key difference between the two is that access to the Hashtable is synchronized on the table while access to the HashMap isn't. You can add it, but it isn't there by default.

Another difference is that iterator in the HashMap is fail-safe while the enumerator for the Hashtable isn't. If you change the map while iterating, you'll know.

And, a third difference is that HashMap permits null values in it, while Hashtable doesn't.

For new code, I would tend to always use HashMap.

Checked versus unchecked exceptions

http://www.javapractices.com/topic/TopicAction.do?Id=129

Unchecked exceptions :
  • represent defects in the program (bugs) - often invalid arguments passed to a non-private method. To quote from The Java Programming Language, by Gosling, Arnold, and Holmes : "Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered from at run time."
  • are subclasses of RuntimeException, and are usually implemented using IllegalArgumentException, NullPointerException, or IllegalStateException
  • a method is not obliged to establish a policy for the unchecked exceptions thrown by its implementation (and they almost always do not do so)
Checked exceptions :
  • represent invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent files)
  • are subclasses of Exception
  • a method is obliged to establish a policy for all checked exceptions thrown by its implementation (either pass the checked exception further up the stack, or handle it somehow)

Wednesday, November 17, 2010

Ajax example

http://www.headfirstlabs.com/books/hrajax/chapter01/

function getBoardsSold() {
createRequest();
var url = "getUpdatedBoardSales-ajax.php";
request.open("GET", url, true);
request.onreadystatechange = updatePage;
request.send(null);
}

function updatePage() {
if (request.readyState == 4) {
if(request.status ==200) {
var somevariable = request.responseText;
document.getElementById("Id").value = somevariable;
...
}
}
}
<--input --value="Show Me the Money" onclick="getBoardsSold();" type="button">

(more event handler)
<--input type="text" name="abc" onChange="getBoardsSold();" >
<--input type="text" name="abc" onFocus="foo();" >
<--input type="text" name="abc" onBlur="foo();" >

<--textarea name ="Id" id = "id" >

Any JavaScript in your web page that is not in a function gets run statically.
if (request == null) check out of function, will have the users know right away. (page 92)

Friday, November 5, 2010

Ajax

1. Asynchronous applications make requests using a JavaScript Object, and not a form submit
2. your request and response are handled by the web browser, not directly by your JavaScript code.
3. Once the web browser gets a response to your asynchronous request, it will 'call back' your JavaScript with the server's response.