Interview Questions from a Mid-Sized Company

I've recently interviewed at a mid-sized company, probably best classified as a "Start-Up." This took place near the Boston metropolitan area. Unfortunately, I may have not answered all of the questions correctly or coherently but I'm certain someone will appreciate this in the future. I've provided a very simple and general response to most and I suggest you do a little more research.

Below are the Java, JS/CSS, and Database questions that I was able to remember. The company had a little more than 50 employees and they were looking for a UI Java Developer.

Q. What does the keyword synchronized mean?
A. That a particular field of an object may only be accessed by one thread at a time.

Q. Can you describe polymorphism?
A. I gave a convoluted answer and the interviewer was actually just looking for "Having multiple forms."

Q. How do you create a thread?
A. You can inherit the Thread class or implement Runnable. You would have to implement Runnable if your class is already extending another class. Java only supports single-inheritance. This question is very common and a good resource is at

Q. What will happen with the following class when you have several threads accessing both methods at a particular instance in time?

class Thing {
void doThis() {
void synchronized doThat() {

A. Each thread that accesses doThis will cause the statement "Hello" to be printed. However, "Goodbye" will only be printed once as every other thread will have to wait until a lock a released on this method. Synchronize will only allow this method to be accessed by one thread at a time.

Q. What's the best way to concatenate or combine several strings?
A. Put the strings in an array and combine them with the join method. Example:

some_text = new Array("Python", "does","this.")
resulting_text = some_text.join(" ");
/* The result is "Python does this." */

Q. Why would you pass JSON instead of XML?
A. In general, parsing data in a JSON object within HTML/JS is typically much faster. A good discussion on "when to prefer JSON over XML" took place on StackOverflow. A user, Robert Rossney wrote:

Favor XML over JSON when any of these is true:

  • You need message validation
  • You're using XSLT
  • Your messages include a lot of marked-up text
  • You need to interoperate with environments that don't support JSON

Favor JSON over XML when all of these are true:

  • Messages don't need to be validated, or validating their deserialization is simple
  • You're not transforming messages, or transforming their deserialization is simple
  • Your messages are mostly data, not marked-up text
  • The messaging endpoints have good JSON tools
Q. What does a JSON object look like? How do you create one?
A. From what I know, it starts and ends with a curly brace. Within it are key-value pairings that describe the data.
"first_name": "Donnie",
"last_name": "Demuth",
"location": {
"city": "San Diego",
"state": "CA"
Q. How do you bind a function to a variable? And why would you do this?
A. Simply assign a function, as you would normally but with or without a name, to a variable. By doing so, you can assign functions to particular Objects or pass a function as an argument. Justin Palmer explains it in a real fun way at Here's a very simple example:
var my_obj = new Object();
my_obj.add = function(x, y) { return x + y };

/* The object has a function named add and you can use it by */
my_obj.add(1, 2);
Q. What is faster, $("p #dog") or $("#dog")?
A. The later is faster, $("#dog") because the first example would first have to find all "p" (paragraph) elements and then parse those elements for the "dog" key. You can simply search for that key immediately because all ids should be unique.

Q. What is faster, $("p") or $(".dog")?
A. Since a class can be used multiple times, the first would be faster. We first narrow down the search and then look for a particular element with the "dog" class-name.


Q. What's the difference between an inner and outer join?
A. An inner join returns a combined set of data where two tables share a common criteria. An outer join is a data set of all records from one table with data from the other where a common criteria is also met.

It's probably best to think about a two-circle Venn-Diagram. The center, or where the two circles overlap could be considered the results of an inner join. An outer join could be either circle and the part other the other where the two overlap.

Q. Describe the relationship between the following three tables: an Employee, an Application, and an Account Table.
int employee_id
String first_name
String last_name
String email

int application_id
String app_name

int account_id
int employee_id
int application_id
A. The Employee and Application tables do not have any foreign relationships. The Account table maps the two tables together, defining which users have access to an Application. The Account table would probably not have unique restraints on the employee_id or application_id columns.

Q. Write a query that returns the email for all users that can access a particular Application. Let's say, an Application with the name of "Sales".
A. Note: There's probably a better way to do this. Here's an excellent write up on multiple sql joins.
Employee.employee_id = Account.employee_id
INNER JOIN Application ON
Account.application_id = Application.application_id
Application.app_name = "Sales";
Q. How would you map these tables to Java objects and what would those objects look like?
A. I would probably create Pojos (plain old java objects) that map directly to these tables.
class Employee {
int id;
String first_name;
String last_name;
Email email; // use a specific Email class for emails

class Application {
int id;
String name;

class Account {
int id;
Employee employee;
Application application;

  1. gravatar

    # by Shawn Oleman - July 22, 2009 at 5:29 AM

    Thanks, this is incredibly helpful.

  2. gravatar

    # by Anonymous - July 22, 2009 at 4:03 PM

    plz post any more db questions when you get them