Java Beginner Questions 1
Java Beginner Questions 1
2. Write a Java program to find the largest of three numbers using if-else.
4. Write a Java program to check whether a given year is a leap year or not.
5. Write a Java program that takes a character as input and checks if it is a vowel or consonant.
9. Write a Java program to display the day of the week based on a number (1-7) using switch-case.
10. Write a Java program that asks for a month number and displays the corresponding month
name.
11. Write a Java program to print numbers from 1 to 10 using a for loop.
12. Write a Java program to print even numbers between 1 and 20 using a while loop.
13. Write a Java program to calculate the sum of digits of a number using a while loop.
15. Write a Java program to print the first 10 Fibonacci numbers using a loop.
16. Write a Java program to print numbers from 1 to 10 but stop at 6 using break.
17. Write a Java program to print numbers from 1 to 10 but skip 5 using continue.
18. Write a Java program to find the factorial of a number using recursion.
19. Write a Java program to find the sum of an array using a function.
21. Write a Java function to find the greatest common divisor (GCD) of two numbers.
27. Write a Java program to find the maximum and minimum element in an array.
28. Write a Java program to find the sum and average of elements in an array.
35. Write a Java program to find the sum of each row and each column in a matrix.
39. Write a Java program to generate and print the first 10 prime numbers.
41. Write a Java program to find the sum of first N natural numbers.
44. Write a Java program to rotate an array to the right by one position.
46. Write a Java program to count the occurrence of a specific element in an array.
47. Write a Java program to find the largest word in a given sentence.
48. Write a Java program to sort an array using the Bubble Sort algorithm.
50. Write a Java program to implement basic stack operations using an array.