26 Programming Interview Questions And Answers

A good Software developer should have good programming concepts. If you have an interview for the position of Software developer, you should expect the programming interview questions that I am going to share in the post below. Do not forget to bookmark this page as this might help you in future as well ūüôā

1. What is the difference between array and list?

The array is a collection of items with a particular order with a fixed length. While the list is a collection of items with a particular order without a fixed size.

2. What is a collection?

The Collection is a set of classes and interfaces that allow us to implement data structures.

3. What is generics?

Generics is a concept in programming in which the type of a method or a class is generalized and specific type is provided as a parameter when the method or class is needed.

4. What is enumeration?

It is a collection of integral constants. Keyword ‘enum’ is used to define an enumeration.

5. What is the difference between concurrent and parallel?

In concurrency, one processor performs 2 tasks. While in parallelism, two processors perform different tasks simultaneously.

6. What is an iterator?

An iterator is a concept that provides a way to iterate a collection or container.

7. What is the diamond problem?

It is an ambiguity that arises when a class inherits the two classes which are derived from a single base class.

Class A (base class)
Class B extends A & Class C extends A
Class D extends B, C

If the class B and class C has overridden a method, class D has no idea which overridden method from either class it should inherit.

8. What are inner classes?

Inner classes are the non-static nested classes.

9. Is String mutable?

The string is immutable, if you try to alter their values, another object gets created, whereas StringBuffer and StringBuilder are mutable so they can change their values.

10. What is the difference between StringBuffer and String Builder?

The difference between StringBuffer and StringBuilder is that StringBuffer is thread-safe. So StringBuilder is more efficient than StringBuffer.

Thread-Safety Difference: when the application needs to be run only in a single thread then it is better to use StringBuilder.

11. What is the different between HashSet and HashMap?

HashSet is a set, e.g. {1,2,3,4,5}

HashMap is a key -> value (key to value) map, e.g. {a -> 1, b -> 2, c -> 2, d -> 1}

Notice in the example above,  HashMap cannot not have duplicate keys, but it may have duplicate values. In the HashSet, it can not contain duplicate elements.

12. What is the difference between HTTP and HTTPS?

HTTP (Hyper Text Transfer Protocol) is a request-response protocol which transfers data between the clients and servers. HTTPS (Hyper Text Transfer Protocol Secure) is a protocol that uses encrypted HTTP connection to keep the transferring data secure.

13. What is the difference between GET and POST?

GET and POST are both HTTP request methods. GET is used for requesting a data from a source. While POST is used for submitting data to a source for processing.

14. What is an API?

An API (Application programming interface) is a collection of subroutine definitions, protocols, and tools for building a software. It interprets the data and sends the required information to you.

15. What is a deadlock?

It is a situation when a resource is being shared by two or more than two processes, and each process is waiting for one process to release the shared resource, which is itself waiting for some other process before it can release it.

16. What is Semaphore?

It is an object that controls the access to a shared resource by multiple processes.

17. What is Mutex?

It is an object that allows the access to a shared resource by multiple processes but one at a time only.

18. What is the difference between Thread and process?

Threads are used for small tasks, whereas processes are used for more ‘heavyweight’ tasks ‚Äď basically the execution of applications. Another difference between a thread and a process is that threads within the same process share the same address space, whereas different processes do not.

19. What is hashing?

It is a transformation of a string value to its key value.

20. What is cryptography?

It is a way to encrypt data in a way that it can only be decrypted by the authorized person.

21. What are synchronized methods?

Synchronised methods are those methods, if called by more than one thread , it waits for its completion if another thread calls it on the same time.

22. Bubble Sort Algorithm 

int arr [ ] = { 4,7,9,2,6,5} ;
for (int i = 0; i < arr.length( )-1 ; i++ ) {
   for int j = 1; j < arr.length( ) ; j++ ) {
       if( arr[i] > arr[j] ) {                           //It is for ascending. For descending, arr[i]<arr[j]
            int temp = arr[i];
            arr[i] = arr [j];
            arr[j] = temp;

23. Fibonacci Series

int n = 10; //n number of terms
int n1 = 0;
int n2 = 1;

for (int i = 1; i <= n; i++) {
¬† ¬† System.out.print(n1 + “\n”); // Java

    int sum = n1 + n2;
    n1 = n2;
    n2 = sum;

24. Factorial 

int result = 1;
int n = 5; //factorial for n
for(int i=1 ; i<=n  ;i++) {
    result = result * i;
//print result which is the calculated factorial 

25. What is big O Notation?

Big O Notation is a term which is used to describe the complexity or performance of an algorithm.

26. What is Dependency Injection?

It is a technique in which an object is being supplied its dependencies at runtime.

I hope the above programming interview questions will prove to be useful for you. If you like it, share it with your friends to whom you feel it will be useful. Best of Luck!



To Top