Netflix Interview Question: How does a garbage collection... | Glassdoor

Interview Question

Senior Software Engineer, Architect Interview Los Gatos, CA

How does a garbage collection system work? How will you

  prevent an object from being garbage collected? Write N-ary tree traversal code to search a node given a String key. How many JVM instances does a tomcat server have? How would it handle multiple applications with different versions of same api (for instance log4j)? Explain wait and notify. Explain Generics. What is the difference between a static class and a singleton class? Why do you want to work for Netflix?
Tags:
java, j2ee, programming, code, phone
Answer

Interview Answer

2 Answers

0

http://www.dofactory.com/topic/1173/difference-singleton-and-static.aspx

Sarty on Apr 12, 2012
1

Answer to static vs singleton class question:
First of all static classes don't exist in Java, only NESTED classes can be static (see http://stackoverflow.com/questions/3584113/java-static-class). Basically when an element of a class is declared static in Java, it can be accessed without having to instantiate the class itself. So the key concept is that no instantiation is needed.
In the singleton the class needs to be instantiated but the key here is that the class can be instantiated only ONCE. It means that if you instantiate A then the next time you need to instantiate A again, your class will basically return the A you created first instead of creating a new A object. You use the Singleton pattern basically to avoid having duplicate objects existing at the same time (hence the word SINGLE in singleton. see http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html).

jule64 on Sep 28, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.