Skip to content

Instantly share code, notes, and snippets.

@rantler
Last active December 27, 2015 10:09
Show Gist options
  • Save rantler/7309428 to your computer and use it in GitHub Desktop.
Save rantler/7309428 to your computer and use it in GitHub Desktop.
Software Developer Interview Questions

(See also https://gist.github.com/ryansobol/5252653)

Originally published November, 2013

Javascript

How would you toggle the visibility of several controls on the page?

$$('#element_one, #element_two').invoke('toggle');

How would you toggle the 'disabled' state of a single control on the page using an onclick even handler?

$('element')[$('element').disabled ? 'enable' : 'disable']();

How would you pass a string within a URL that contained a forward slash symbol?

url = 'http://my.server.com/controller/action/' + URI::encode('some/string/with/slashes')

How would you transform a Hash of data in JS into a form suitable for appending to a URL?

 $H({key_one: 'value_one', key_two: 'value_two'}).map(function(item) {
   return item.key + '=' + item.value;
 }).join('&')

Describe the difference between these two variable declarations:

var localVariable = "TechRepublic";
globalVariable = "CNet";

Describe these different comparisons.

someVar === null
someVar === Undefined
someVar == null
someVar == undefined
someVar === "undefined"

Describe event bubbling.

Describe event capture.

Describe javascript testing frameworks.

Describe javascript error handling. What is bad about rescuing exceptions?

Describe how setTimeout can be used. What if multiple timeouts a running and you want to cancel one of them?

Any experience with Backbone.JS, Ember.JS or Angular.JS?

Ruby

How would you sum an array of values?

How would you sum the values of a hash?

How would you create a hash from an array of key/value pairs?

How would you add a method to an existing class?

What are modules and how are they used? What's the difference between "include" and "extend"?

What is the difference between symbols and strings? Is there anything bad about symbols?

What is a good way to concatenate two strings? What is the difference between + vs. << ?

What is the yield statement all about?

What is the difference between an instance variable and a class variable? What are class instance variables?

What does attr_accessor do?

How do you declare an instance method on a class? How do you declare a class method on a class? How do you declare an instance method on a class at runtime? What is a singleton method?

What is the difference between these three operators? &&, &, and

What is the convention of ending a method name in "!"?

How do you handle exceptions in Ruby? (Do they know about "finally"?)

How do you invoke the base class's implementation of a method in a subclass?

Rails

What is MVC?

What is RESTful routing?

What is ActiveRecord? What are validations and how are they used? Bonus: What happens when you add a new validation to existing models? What are associations? What kinds of associations are there? What is eager loading? What are scopes? What are filters? (aka callbacks) What is STI? What is a polymorphic association?

What are migrations? What goes in a migration?

How is caching typically performed in Rails? (Ask about view caching vs. non-view caching.)

What are layouts and why would you use more than one?

What are partials and why are they useful?

What kind of testing frameworks have you used? (Ask about front-end testing vs. back-end testing.)

SQL

How would you create a table with a primary key, a string field, an integer field and a text (blob) field? i.e. create table (id int, name varchar, category_id int, value int, description text)

How would you create indexes on these fields? Which fields? Unique?

How would you select all unique values for the string field?

How would you count how many records there are for each unique value of the integer field?

How would you show the unique name and count for each record that belongs to a given set of category_id values?

What is a join table? What are the different types of joins?

What is the difference between a primary key and a foreign key? What is a surrogate key?

What is a trigger?

What is a cursor?

What is a stored procedure?

What is a subquery?

What is an index and why are they useful?

What is ACID and why is it desirable?

Talk about the difference between normalization and de-normalization.

What are some different kinds of locking? i.e. optimistic locking, pessimistic locking.

What is the difference between CHAR and VARCHAR types?

What is a SQL injection attack and how might one protect against it?

Java

How does Java differ from dynamically typed languages?

What is MVC? Can you draw a simple picture that describes the interaction between the three elements?

What is OO?

What is polymorphism?

What is coupling?

What is overloading?

What is overriding?

What is the singleton pattern?

What is auto-boxing?

What are enums?

What are inner classes? What is the difference with them and nested classes?

Why would a class be both abstract and final? This is not actually legal in Java. The idea is to talk about classes that should not be instantiated vs. classes that must be subclassed. Prevent a class from being instantiated by making its constructor private. Prevent a class from being used with subclassing it by making it abstract.

What is the relationship between the equals() and hashCode() methods? If x.equals(y) then x.hashCode() == y.hashCode()

Why is the public static void main(String[] args) method declared this way? Must be public to be reachable from any package (i.e. JVM). Must be static to be callable without an instance. Must be void because it is not expected to return a value. Must accept String array of args specified during launch.

Describe the differences and likely uses of List, Set and Map collection classes.

What are generics and why are they used?

Why are so many GoF patterns manifest in Java, as opposed to dynamically typed languages? Just trying to get candidate talking about differences between statically/dynamically typed languages and how many GoF patterns simply working around the limitations of statically typed languages.

What happens when an exception is raised in the finally block?

Why would you override the toString() method?

Does Java support multiple inheritance? No, not for classes, but it does allow a single class to implement multiple interfaces.

What is the difference between and abstract class and an interface? One can only extend one abstract class. One can extend multiple interfaces. Abstract classes can contain methods and instance variables, interfaces cannot.

How does object serialization work? Declare that your class implements the Serializable interface. Any instance variables that cannot / should not be serialized are marked transient.

How does on go about implementing Comparable? Implement the method compareTo() which returns -1, 0, or 1

What are JDBC prepared statements and why would one want to use them?

What are the various access modifiers? private - class visibility protected - package and subclass visibility public - world visibility default - package visibility

Write some code that will cause a NPE to be thrown throw new NullPointerException() is acceptable. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment