Search results
Nov 24, 2022 · Prepare for your Java coding interview with these common questions and answers. Learn how to reverse a string, swap numbers, check for vowels, primes, palindromes, and more.
- Write a Java program for generating the nth Fibonacci Number using loop and O(1) space. In a Fibonacci series, the value of any term is the sum of the values of the last two terms.
- Write a Java program for counting the digits present in a number. If we take a number 5647, we find that the number consists of 4 digits that are 5, 6, 4, and 7.
- Calculate how many times a digit D occurs in the number N. One has to ask the user to give the values of N and D. The question is a modified form of the previous question.
- Compute the value of an using recursion. It is not allowed to use any extra space apart from the recursion call stack. In a recursion, one needs to look for the relation between the larger problem and the smaller problem.
Oct 4, 2024 · Prepare for Java interviews with 200+ core questions for freshers and experienced professionals. Learn about Java features, concepts, OOP, multithreading, collections, and more with examples and explanations.
- Nested Loop with Addition. Find the Big O complexity of the following code: class NestedLoop { public static void main(String[] args) { int n = 10; // 1 step --> Note: n can be anything.
- Nested Loop with Multiplication. Find the Big O complexity of the following code segment: class NestedLoop { public static void main(String[] args) { int n = 10; // O(time complexity of the called function) int sum = 0; //O(1) double pie = 3.14; //O(1) int var = 1; while(var < n) { // O(log n) System.out.println("Pie: " + pie); // O(log n) for (int j = 0; j < var; j++) { // 2n sum++; // (2n-1) } var *= 2; // O(log n) } //end of while loop System.out.println("Sum: " + sum); //O(1) } //end of main } //end of class.
- Nested Loop with Multiplication (Advanced) Find the Big O Complexity of the following code segment: class NestedLoop { public static void main(String[] args) { int n = 10; int sum = 0; double pie = 3.14; for (int var = 0; var < n; var++) { int j = 1; System.out.println("Pie: " + pie); while(j < var) { sum += 1; j *= 2; } } //end of for loop System.out.println("Sum: " + sum); } //end of main } //end of class.
- Conditional Loop. What is the Big O complexity of the following code segment: void complexMethod(int[] array) { int n = array.length; int runFor = Math.pow(-1, n) * Math.pow(n, 2); for (int i = 0; i < runFor; i++) { System.out.println("Find how complex I am ?") } }
Prepare for Java coding interviews with 30 questions that cover core concepts, advanced features and performance optimization strategies. Find out what to expect and how to solve problems in different levels of difficulty.
Jan 2, 2024 · Prepare for your Java coding interview with this collection of 2024 questions and answers on various topics such as basics, strings, arrays, matrices, OOPS, multithreading and exceptions. Download the PDF guide and get a free personalized career roadmap.
People also ask
How to prepare Java coding interview questions for beginners?
Why is Java coding important in a Java interview?
Do Java coding skills matter in a Java interview?
How coding tasks help recruiters design coding questions for candidates?
How many Java interview questions are there?
How do I prepare for coding interviews?
Learn and practice 20 common Java language-specific interview questions on topics such as varargs, generics, lambda expressions, and more. See code examples, answers, and explanations for each question.