Example interview for Java beginners 2018

Dear Java beginners,
please find interview questions for Java beginners and internship programs which are collected from several different companies from the IT world. All questions may vary a lot depending on the company, the interviewer, Java version, position and your background.
From my experience the good interviewer will ask question until he find area which is unknown for you. Then he will try to find your way of thinking, do you have solving attitude for unexpected problems and how do you deal with something new. Another important point to remember for your first interview (not only for Java) is that interviewer wants to understand what is the personality behind the person who apply for his open position. If you are stubborn, whimsical, selfish, lazy, party guy, solo or team player - all this is important for him because he is trying to find a match for his team. So you need to fit in his optimal candidate person.

Java question for beginners 2018

The example questions below include the latest features introduced in Java 9 and Java 10.

  1. What is an interface?

  2. What is an abstract class?

  3. What is the difference between abstract class and interface?

  4. What is Java Annotations?

  5. What is composition in Java ?

  6. What is anonymous inner class?

  7. What is "this" keyword?

  8. What is java method references?

  9. What is Garbage Collection?

  10. Java is Pass by Value or Pass by Reference?

  11. What is difference between Heap and Stack Memory?

  12. What is JIT compiler?

  13. What is the default value of the local variables?

  14. What is the purpose of default constructor?

  15. Is constructor inherited?

  16. Can you make a constructor final?

  17. What is difference between static (class) method and instance method?

  18. Can you use this() and super() both in a constructor?

  19. What is method overriding? Give example.

  20. Can you have virtual functions in Java?

  21. What is difference between final, finally and finalize?

  22. What is difference between Checked Exception and Unchecked Exception?

  23. Can finally block be used without catch?

  24. How many objects will be created in the following code?

  25. How many objects will be created in the following code?

  26. What is reflection?

  27. What is deadlock?

  28. What is the difference between ArrayList and LinkedList?

  29. What is the difference between List and Set?

  30. What is hash-collision in Hashtable and how it is handled in Java?

  31. What is local-variable type inference?

  32. What is Java REPL or Jshell?

  33. What can you do with REPL or Jshell?

  34. What is the Module System introduced in Java 9?

  35. What are the collection factory methods?

  36. Is it possible to have Multi-release JARs in Java? Since which version?

  37. Does Java support lambda functions?

  38. What is a functional interface in Java?

  39. What is the Java Stream API?

  40. What is the meaning of str::toString; ?

  41. What is the difference between a streams and collections?

Java exercise for beginners 2018

Next simple exercises are good starting point if you want to prepare for interview for Java.

Exercise 1. Implement DFS(Depth First Search) for a binary tree in Java

Exercise 2. A palindrome is a word, phrase, number or other sequence of units that can be read the same way in either direction. Write a method that check if a string is a palindrome.

Exercise 3. Implement Builder pattern.

Exercise 4. Each new term in the Fibonacci sequence is generated by adding the previous two terms:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Write non recursive Java program to calculate 1000 member of this sequence.

Exercise 5. The prime factors of 13195 are 5, 7, 13 and 29. Write a program to find prime factors for any number?

Exercise 6. The prime numbers are: 2, 3, 5, 7, 11, and 13 .. this are numbers which can divide only on themselves. Write a program to find if the N-th number is a prime or not.

Exercise 7. You are given the next rules(this is related to SQL and DB knowledge):

  • a person has a name, surname and birth date
  • team has a name
  • project has a name
  • every person can be in one or more teams
  • in every team there could be one or more people
  • each team work on a separate project

Can you:

  • do a ER (UML) diagram and create a database for it?
  • write a query in order to extract all persons working for team XXX
  • write a query in order to get all teams(only name)
  • write a query to find the 5 oldest persons
  • write a query to extract all people from team XXX sorted by birth date
  • write a query which extract all people working in projects with exactly 3 letters name
  • write a query which extract all people working in projects which name starts with X

Additional questions relate to DB:

  • What is a trigger in DB?
  • What is normalization in DB?
  • What is the difference between SQL and NoSQL DB?
  • Can Java work and access data from NoSQL DB?
  • Name a one SQL and one NoSQL DB?

Related Article