Core Java - Programming - Coding Interview Questions and Answers
- 1 Write a Java program to check if a number is Armstrong or not ?
- 2 Write a Java program to prevent deadlock in Java?
- 3 Write Java program to reverse String in Java without using API functions?
- 4 Write a Java program to find if a number is prime number or not?
- 5 How to Swap two numbers without using third variable in Java?
- 6 Create a Java program to find middle node of linked list in Java in one pass?
- 7 How to find if a linked list contains cycle or not in Java?
- 8 Implement Producer Consumer design Pattern in Java using wait, notify and notifyAll method in Java?
- 9 Write a Java program to calculate Factorial of a number in Java?
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.
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.
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