[Solved] Source folder is not a Java Project error in Eclipse

If you are trying to import maven project into eclipse or creating a maven web project in eclipse, it might be possible that you face following error : Source folder is not a Java project. There are two ways to solve this error. One is using mvn eclipse:eclipse (deprecated) and other is by converting project into faceted form.

Read Also :   Java Was Started by Returned Exit Code=13 Error in Eclipse

Understand the error

This error occurs when the project created by you is not a java project in eclipse. If you try to add new java class to such project then "Source folder is not a Java Project error" occurs.

Frequently Asked HashMap Interview Questions in Java

HashMap is one of the tricky java class in java collections framework. Unlike other java classes its object contains both key and value pair. This is one of the most frequently used java class along side ArrayList. In this tutorial I will be sharing frequently asked HashMap interview questions with answers. 

Q1 How HashMap internally works in java 8? (solution)

This question is the most popular interview question for java developers. The get() method of HashMap works on the principle of Hashing. TreeNode concept is introduced in java 8 to store key-value pairs. You can find the detailed explanation here.

Q2 What is the difference between HashMap and Hashtable in java ? (solution)

1. The main difference between Hashtable and HashMap is that HashMap can contain one null key and any number of null values but Hashtable does not allow null values.
2. Hashtable is synchronized while HashMap is not synchronized.
3. HashMap is faster as compared to Hashtable because HashMap is not synchronized.

Q3 What is the difference between HashMap and ConcurrentHashMap in java ? (solution)

1. ConcurrentHashMap is thread-safe that is at a time only one thread can access the code whereas HashMap is not thread-safe.
2. ConcurrentHashMap does not allow keys to contain null values whereas HashMap can contain one null key.

Q4 What is the threshold value after which bucket converted from linked list to Tree?

4 Difference between TreeMap and TreeSet in Java with Example

I have shared a lot of Java Collections Framework tutorial on this blog. Adding to this list is yet another tutorial which is difference between TreeMap and TreeSet in java with examples. This question is similar to the question difference between Map and Set interfaces with some minor tweaks. In this post we will learn about the differences, similarities and examples of TreeMap and TreeSet.

Read Also :  Difference between TreeMap and HashMap in Java

Difference between TreeMap and TreeSet in Java

Interface : TreeMap implements Map interface while TreeSet implements Set interface.

Duplicates : TreeMap allows duplicate values while TreeSet does not allow duplicate objects.

Implementation : TreeMap is a red-black tree based NavigableMap implementation.
TreeSet is a NavigableSet implementation based on a TreeMap. 

Sorting : TreeMap is sorted based on keys while TreeSet is sorted based on objects.

Difference between Collection and Collections in Java with Examples

Difference between Collection and Collections is an important interview question for  java freshers.
This question has been used to test the knowledge of Java Collections Framework. Make sure you go through this question before appearing for the interview.
This question is quite confusing as both Collection and Collections are looking similar by name. But they are completely different. Collection is an interface while Collections is a utility class. In this post, I will be sharing the difference between Collection and Collections in java along with examples.

Read Also :  Java Collections Interview Questions and Answers

Difference between Collection and Collections in Java :

1. Type : Collection is a root level interface in Java Collection Framework or collection hierarchy.
Collections is a utility class in java which contains only static methods that operate on or return collections.

Difference between Collection and Collections in Java


Top 50 Java Array Interview Questions and Answers

Array is one of the topic you just can't miss for interview preparation. In this post I will be sharing 50 most frequently asked java Array interview questions and answers. 

Q1 What is an Array?

  1. Array is a collection of similar data types. It can not have different data type. It can hold both primitive types (int, float, double) and object references.
  2. It is fixed in length i.e static in nature. 
  3. Arrays are created on the heap memory not on the stack.
  4. Accessing an invalid index of an Array will cause exception.

Q2 How do you declare an Array in java?

You can declare an Array in java by the following way :

dataType[]    arrayVariableName  = new dataType[arraySize];

for example for int data type, you can declare an int array as :

int[]  temp = new int[256]

Q3 What is the default value of Array for different data types?