50+ Easy Java Programs for Wipro WILP Interview
1. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
2. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
3. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
4. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
5. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
6. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
7. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
8. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
9. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
10. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
11. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
12. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
13. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
14. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
15. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
16. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
17. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
18. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
19. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
20. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
21. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
22. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
23. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
24. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
25. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
26. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
27. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
28. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
29. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
30. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
31. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
32. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
33. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
34. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
35. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
36. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
37. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
38. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
39. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
40. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
41. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
42. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
43. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
44. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
45. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
46. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
47. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
48. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
49. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
50. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321
51. Check if a Number is Even or Odd
public class EvenOdd {
public static void main(String[] args) {
int num = 10;
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output: Even
52. Find the Largest of Two Numbers
public class LargestOfTwo {
public static void main(String[] args) {
int a = 10, b = 20;
if (a > b)
System.out.println("Largest is: " + a);
else
System.out.println("Largest is: " + b);
}
}
Output: Largest is: 20
53. Find Factorial of a Number
public class Factorial {
public static void main(String[] args) {
int num = 5, fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
System.out.println("Factorial: " + fact);
}
}
Output: Factorial: 120
54. Check Leap Year
public class LeapYear {
public static void main(String[] args) {
int year = 2024;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}
Output: Leap Year
55. Reverse a Number
public class ReverseNumber {
public static void main(String[] args) {
int num = 1234, rev = 0;
while (num != 0) {
rev = rev * 10 + num % 10;
num = num / 10;
}
System.out.println("Reversed Number: " + rev);
}
}
Output: Reversed Number: 4321