0% found this document useful (0 votes)
25 views2 pages

Java Problems For Beginners

Uploaded by

deeksha32005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Java Problems For Beginners

Uploaded by

deeksha32005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Simple Java Problems for Beginners

1. Write a Java program to print "Hello, World!"


2. Write a Java program to add two numbers.
3. Write a Java program to find the factorial of a number.
4. Write a Java program to check if a number is prime.
5. Write a Java program to find the largest of three numbers.
6. Write a Java program to print the Fibonacci series up to n terms.
7. Write a Java program to reverse a string.
8. Write a Java program to check if a string is a palindrome.
9. Write a Java program to calculate the sum of digits of a number.
10. Write a Java program to find the greatest common divisor (GCD) of two numbers.
11. Write a Java program to sort an array in ascending order.
12. Write a Java program to find the second largest number in an array.
13. Write a Java program to count vowels and consonants in a string.
14. Write a Java program to check if a year is a leap year.
15. Write a Java program to calculate the area of a circle given its radius.

Basics & Operators

16. Write a Java program to swap two numbers using a temporary variable.
17. Write a Java program to swap two numbers without using a temporary variable.
18. Write a Java program to check whether a number is even or odd.
19. Write a Java program to find the quotient and remainder when dividing two
numbers.
20. Write a Java program to convert Celsius to Fahrenheit.

Loops & Patterns

21. Write a Java program to print the multiplication table of a number.


22. Write a Java program to calculate the sum of natural numbers up to n.
23. Write a Java program to print a pyramid pattern using *.
24. Write a Java program to print the Pascal’s Triangle.
25. Write a Java program to print numbers in reverse order using a loop.

Arrays

26. Write a Java program to calculate the sum of elements in an array.


27. Write a Java program to find the minimum and maximum elements in an array.
28. Write a Java program to check if an array contains a specific element.
29. Write a Java program to merge two arrays.
30. Write a Java program to find the frequency of each element in an array.

Strings

31. Write a Java program to count words in a string.


32. Write a Java program to remove all spaces from a string.
33. Write a Java program to convert a string to uppercase and lowercase.
34. Write a Java program to find the longest word in a sentence.
35. Write a Java program to find the first non-repeating character in a string.

Functions & Recursion

36. Write a Java program to calculate the power of a number using recursion.
37. Write a Java program to find the greatest common divisor (GCD) using recursion.
38. Write a Java program to find the least common multiple (LCM) of two numbers.
39. Write a Java program to implement a simple calculator using switch.
40. Write a Java program to find the sum of digits using recursion.

You might also like