Core Java - Programming - Coding Interview Questions and Answers

Write a Java program to check if a number is Armstrong or not ?

Another popular logical coding interview questions in Java, which is based on programming logic. In order to answer this programming question, you need to know what is Armstrong number, but that is not a problem because question may specify that and even provide sample input and output.

The key thing to demonstrate is logic to check if a number is Armstrong or not. In most cases, you can not use utility methods defined by logic and you need to produce logic by yourself by using basic operators and methods.

Write a Java program to prevent deadlock in Java?

Some of the programming or coding interview question is always based on fundamental feature of Java programming language e.g. multi-threading, synchronization etc. Since writing deadlock proof code is important for a Java developer, programming questions which requires knowledge of concurrency constructs becomes popular coding question asked in Java Interviews.

The deadlock happens if four condition is true e.g. mutual exclusion, no waiting, circular wait and no preemption. If you can break any of this condition than you can create Java programs,which are deadlock proof.

Write Java program to reverse String in Java without using API functions?

Another classic Java programming or coding exercise mostly asked on 2 to 5 years experienced Java interviews. Despite being simple answering this coding question is not easy, specially if you are not coding frequently. Its best to prepare this programming question in advance to avoid any embarrassment during interviews. I suggest to see this post which shows How to reverse String using recursion in Java

Write a Java program to find if a number is prime number or not?

How to Swap two numbers without using third variable in Java?

Create a Java program to find middle node of linked list in Java in one pass?

How to find if a linked list contains cycle or not in Java?

Implement Producer Consumer design Pattern in Java using wait, notify and notifyAll method in Java?

Write a Java program to calculate Factorial of a number in Java?