Interview Questions I received in 2017 and 2018 Table of Contents INTERVIEW QUESTIONS I RECEIVED IN 2017 AND 2018... 1 1 OOPS... 3 1. What is the difference between Abstract and Interface in Java8?... 3 2. Does Java8 allow multiple inheritance?... 3 3. What is a Functional Interface in Java8?... 3 4. What is Polymorphism?... 3 5. Is Overriding or Overloading a type of Polymorphism?... 3 6. What is Abstraction?... 3 7. What is Encapsulation?... 3 STRINGS... 3 8. Why is string immutable?... 3 9. What is the difference between String, Stringbuffer and StringBuilder?... 3 10. Strings Literal, New where allocated?... 3 11. Strings == and equals for Literal strings vs New strings and Literal strings vs Literal strings and New strings vs New strings. 4 12.... 3 COLLECTIONS/INTERFACES... 3 13. What is the difference between vector and arraylist?... 3 14. What is the difference between a vector, LinkedList and ArrayList?... 3 15. Why do we need HashMap when we have Hashtable?... 3 16. Create HashMap what do we need to do? Override hashcode and equals.... 3 17. What happens with HashMap collisions? Can set to either overwrite bucket or use Java7 linked list or Java8 tree... 3 18. When to override equals() and hashcode?... 3 19. How to printout Employee object? Override tostring();... 3 20. What is the difference between ArrayList and Vector?... 3 21.... 3 RESTFUL MESSAGING... 3 22. How do you write a Restful message?... 3 23. How do you code a Read or Delete?... 3 MULTITHREADED... 3 24. How do you write multithreaded code?... 3 25. What is the difference between StringBuffer and StringBuilder... 3 26. What can cause a memory leak?... 3 27. What is the difference between a transient and volatile variable?... 4 28. How do you dump thread info in Linux.... 4 29. Best way to protect variable if with few writes and many read threads? Don t want to tie up var because have thousands of read threads.... 4 30. Does Java have semaphores?... 4 31. How do you track the number of threads you have?... 4 32. Have you written Producer Consumer Pattern?... 4 WHITEBOARDING... 4 33. Can you write a Singleton implementation?... 4 34. Write code for a RESTful GET.... 4 35. Write an abstract class... 4 36. Write SQL query to find differences between table 1 and table 2?... 4 37. Write a method to swap two variables without using a temp variable?... 4 MISC... 4 38. What is a class?... 4 39. What is a instance variable?... 4 40. What is a Class or static variable?... 4 41. What is the difference between final, finally and finalize?... 4 42. What is the difference between Comparable and Comparator?... 4 43. What is boxing and unboxing?... 4
44. What is garbage collection?... 4 45. 46. Can you subclass a private class?... 4 What is Serializable?... 4 47. 48. Does Java pass by Reference or Value?... 4 What is a classloader?... 4 49. 50. Name some Functional and Procedural languages?... 5 What is a Functional Interface in Java8?... 5 51. What is a marker interface?... 5 2
3 You can find all the answers to the following questions on this web site. I just wanted to document what interviewer questions I ve faced in the past couple of years. OOPS 1. What is the difference between Abstract and Interface in Java8? 2. Does Java8 allow multiple inheritance? 3. What is a Functional Interface in Java8? 4. What is Polymorphism? 5. Is Overriding or Overloading a type of Polymorphism? 6. What is Abstraction? 7. What is Encapsulation? Strings 8. Why is string immutable? 9. What is the difference between String, Stringbuffer and StringBuilder? 10. Strings Literal, New where allocated? Collections/Interfaces 11. What is the difference between vector and arraylist? 12. What is the difference between a vector, LinkedList and ArrayList? 13. Why do we need HashMap when we have Hashtable? 14. Create HashMap what do we need to do? Override hashcode and equals. 15. What happens with HashMap collisions? Can set to either overwrite bucket or use Java7 linked list or Java8 tree 16. When to override equals() and hashcode? 17. How to printout Employee object? Override tostring(); 18. What is the difference between ArrayList and Vector? Restful Messaging 19. How do you write a Restful message? 20. How do you code a Read or Delete? Multithreaded 21. How do you write multithreaded code? 22. What is the difference between StringBuffer and StringBuilder 23. What can cause a memory leak?
24. What is the difference between a transient and volatile variable? 25. How do you dump thread info in Linux. 26. Best way to protect variable if with few writes and many read threads? Don t want to tie up var because have thousands of read threads. 27. Does Java have semaphores? 28. How do you track the number of threads you have? 29. Have you written Producer Consumer Pattern? Whiteboarding 30. Can you write a Singleton implementation? Yes. I start writing an ENUM implementation and the Credit Suisse VP that was interviewing me said wait that s cheating. Use something else! 31. Write code for a RESTful GET. 32. Write an abstract class 33. Write SQL query to find differences between table 1 and table 2? 34. Write a method to swap two variables without using a temp variable? 35. Literal and New String examples. Are the two Literal Strings == and.equals(). Are the two New Strings == and.equals(). Is the Literal String and New String == and.equals(). 36. Calculate the Fibonacci value for a number X 37. Determine whether or not a given number X is prime 38. Reverse an array without using a loop 39. FizzBuzz Misc 40. What is a class? 41. What is a instance variable? 42. What is a Class or static variable? 43. What is the difference between final, finally and finalize? 44. What is the difference between Comparable and Comparator? 45. What is boxing and unboxing? 46. What is garbage collection? 47. Can you subclass a private class? 48. What is Serializable? 49. Does Java pass by Reference or Value? 50. What is a classloader? 4
51. Name some Functional and Procedural languages? 52. What is a Functional Interface in Java8? 53. What is a marker interface? 54. What are checked and unchecked exceptions? 55. Can I throw and integer? 56. Can I have a try without a catch? 57. Can I override a private method? 58. What is JAR file? JAR files is Java Archive files and it aggregates many files into one. It holds Java classes in a library. JAR files are built on ZIP file format and have.jar file extension. 59. What is a WAR file? This is Web Archive File and used to store XML, java classes, and JavaServer pages. which is used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, static Web pages etc. 5