четверг, 28 июня 2018 г.

Java 8 programming interview questions

Hi all.
I decided to share with you some stuff which could be useful for the beginners.

Every time you go to the Java interview you almost always get the familiar set of questions. Here is the list of questions that in my opinion are commonly asked at the interviews.

I won't give answers in this post for now. Feel free to explore them on your own.

  • Class Object in Java. Methods equals, hashCode, toString. Default implementation.
  • StringBuilder and StringBuffer. What is the difference? Compare strings by == and equals. String pool.
  • Collections. Basic interfaces and collections. ArrayList and LinkedList. HashMap default implementation. Difference between HashMap and LinkedHashMap and TreeMap.
  • Threads. Thread class. Interface Runnable. Monitor object. Methods wait, notify, notifyAll. Interface Executor. Synchronized keyword. Volatile keyword. Thread-safe collections. Dining philosophers.
  • Difference between interface and abstract class.
  • Lambda expressions. Default methods in interfaces.
  • Exceptions. Checked and unchecked. Difference.
  • Keyword final on class, method, instance member variable, method argument.
  • Try/catch/finally. Cases when finally block will not get executed. 
  • Basic principles of garbage collector.
  • GoF templates. Examples. Do not mention Singleton. Visitor, Adapter, Builder, Template method, Strategy.
  • Basic SOLID principles.
  • What is TDD?
 One of my favorite question is the following: you've got a class which contains one synchronized and one non synchronized method. What will happen if on one instance of this class will operate two threads, one will call synchronized method the other one will call non synchronized method? Is it possible to occur at once?

Answer: One thread can call synchronized method and another one can call  non synchronized method. Synchronized keyword means that a thread needs to obtain object's monitor first. If there are no such word on a method then nothing stops the second thread to operate on an object.
Usually there are other questions about Spring, Databases, J2EE but let's leave it for now. 

That is all for now. Good luck!

Комментариев нет:

Отправить комментарий