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.
-
What is an interface?
-
What is an abstract class?
-
What is the difference between abstract class and interface?
-
What is Java Annotations?
-
What is composition in Java ?
-
What is anonymous inner class?
-
What is "this" keyword?
-
What is java method references?
-
What is Garbage Collection?
-
Java is Pass by Value or Pass by Reference?
-
What is difference between Heap and Stack Memory?
-
What is JIT compiler?
-
What is the default value of the local variables?
-
What is the purpose of default constructor?
-
Is constructor inherited?
-
Can you make a constructor final?
-
What is difference between static (class) method and instance method?
-
Can you use this() and super() both in a constructor?
-
What is method overriding? Give example.
-
Can you have virtual functions in Java?
-
What is difference between final, finally and finalize?
-
What is difference between Checked Exception and Unchecked Exception?
-
Can finally block be used without catch?
-
How many objects will be created in the following code?
-
How many objects will be created in the following code?
-
What is reflection?
-
What is deadlock?
-
What is the difference between ArrayList and LinkedList?
-
What is the difference between List and Set?
-
What is hash-collision in Hashtable and how it is handled in Java?
-
What is local-variable type inference?
-
What is Java REPL or Jshell?
-
What can you do with REPL or Jshell?
-
What is the Module System introduced in Java 9?
-
What are the collection factory methods?
-
Is it possible to have Multi-release JARs in Java? Since which version?
-
Does Java support lambda functions?
-
What is a functional interface in Java?
-
What is the Java Stream API?
-
What is the meaning of str::toString; ?
-
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?