SOOPRO Pathshala provides JAVA Exercises
SOOPRO Pathshala Exercises
1. Write a Java program to print 'Hello World' on screen and your name on a separate line.
2. Write a Java program to print the sum of two numbers.
3. Write a Java program to divide two numbers and print them on the screen.
5. Write a Java program that takes two numbers as input and displays the product of two numbers.
6. Write a Java program to print the sum (addition), multiply, subtract, divide and remainder of two numbers.
7. Write a Java program to compute the specified expressions and print the output.
Test Data:
((10.3 * 4.5 - 2.5 * 1.5) / (30.5 - 3.5))
8. Write a Java program to print the area and perimeter of a circle.
9. Write a Java program to calculate and print the average of the numbers.
10.Write a Java program to print the area and perimeter of a rectangle.
SOOPRO Pathshala Exercises
1. Write a Java program to swap two variables.
2. Write a Java program to convert cm to meter.
3. Write a Java program to convert ml to liter.
4. Write a Java program to print square of given integer number.
5. Write a Java program to print cube of given integer number.
6. Write a Java program to convert inch to feet.
7. Write a Java program to convert feet to inch.
8. Write a Java program to convert km to meter.
9. Write a Java program to convert meter to km.
10. Write a Java program to convert kg to gram.
SOOPRO Pathshala Exercises
1. Write a Java program to convert gram to kg.
2. Write a Java program to convert feet to cm.
3. Write a Java program to print sum of three long numbers.
4. Write a Java program to print simple interest.
5. Write a Java program to print diff of area of circle and circm of circle.
6. Write a Java program to print diff of area of traingle and area of circle.
7. Write a Java program to print average of two float numbers.
8. Write a Java program to print sum of square and cube of given number.
9. Write a Java program to print current date and time.
10. Write a Java program to print current time.
SOOPRO Pathshala Exercises
1. Write a Java program that reads a number in inches and converts it to meters.
2. Write a Java program to convert minutes into years and days.
3. Write a Java program that prints the current time in GMT.
4. Write a Java program to accept and display your name.
5. Write a program to accept and display salary in float.
6. Write a Java program to accept and display your id.
7. Write a program that takes two integer numbers and print sum of numbers.
8. Write a program that takes three float numbers and print sum of numbers.
9. Write a program to print square of any number.
10. Write a program to print cube of any number.
SOOPRO Pathshala Exercises
1. Write a Java program that reads a number and displays the square, cube, and fourth power.
2. Write a Java program that accepts two integers from the user and prints the sum, the difference, the product, the average, the division and the remainder.
3. Write a Java program to concatenate first and last name by user input.
4. Write a Java program to print sum of one float and one integer number.
5. Write a Java program to print sum of one long and one double number.
SOOPRO Pathshala Exercises
1. Write a program to find maximum between two numbers using conditional operator.
2. Write a program to find maximum between three numbers using conditional operator.
3. Write a program to check whether a number is even or odd using conditional operator.
4. Write a program to check whether year is leap year or not using conditional operator.
5. Write a program to check whether character is an alphabet or not using conditional operator.
6. Program to Check Whether a Character is Vowel or Consonant using Conditional operator
7. Program to Check Character is Alphabet, Digit or Special Character using Conditional operator
8. program to check whether a character is Uppercase or Lowercase using Conditional operator
9. Program to find smallest among three numbers using Conditional operator
10. Program to check whether the given integer is positive,negative or zero using Conditional operator
SOOPRO Pathshala Exercises
1. Program to print largest of two numbers using conditional operator
2. Program to print smallest of two numbers using conditional operator
3. Program to print largest of three numbers using conditional operator
4. Program to print smallest of three numbers using conditional operator
5. Program to print enter number is even number or odd number using conditional operator
6. Program to print check leap year or common year using Conditional operator
7. Program to check alphabet or no alphabet using conditional operator
8. Program to check alphabet or no alphabet using ASCII value and conditional operator
9. Program to check vowel or consonant using conditional operator
10. Program to check vowel or consonant using ASCII value and conditional operator
SOOPRO Pathshala Exercises
1. Program to check alphabet, digit or special symbal using conditional operator
2. Program to check alphabet, digit or special symbal using ASCII value and conditional operator
3. Program to check enter alphabet is upper case or lower case using conditional operator
4. Program to check enter alphabet is upper case or lower case using ASCII value and conditional operator
5. Program to check the given integer is positive,negative or zero using and conditional operator
6. Program to check enter week number and print day of week using conditional operator
7. Program to check print number of days in month using conditional operator
8. Program to check print number of days in month using or operator and conditional operator
9. Program to check print number of days in month and month name using conditional operator
10. Program to check print check triangle validity when angles are given using conditional operator.
SOOPRO Pathshala Exercises
1. Program to check valid triangle when sides are given using logical AND operator and conditional operator
2. Program to check isosceles,scalene or equilateral triangle when sides are given using conditional operator
3. Program to check calculate profit or loss using conditional operator
4. Program to enter student marks and find percentage and grade using conditional operator
5. Write a program to add 8 to the number 2345 and then divide it by 3. Now, the modulus of the quotient is taken with 5 and then multiply the resultant value by 5. Display the final result
6. Write a program to check if the two numbers 24 and 45 are equal.
7. Write a program to print the power of 7 raised to 5.
8. The total number of students in a class are 90 out of which 45 are boys. If 50% of the total students secured grade 'A' out of which 20 are boys, then write a program to calculate the total number of girls getting grade 'A'.
9. Write a program to calculate the sum of the digits of a 3-digit number.
10. Write a program to reverse a 3-digit number
11. Check if the string "apple" is equal to the string "banana" using the equality operator. Print the result.
SOOPRO Pathshala Exercises
1. Write a Java program to get a number from the user and print whether it is positive or negative.
2. Write a Java program that takes three numbers from the user and prints the greatest number.
3. Write a Java program that takes a number from the user and generates an integer between 1 and 7. It displays the weekday name.
4. Write a Java program that reads two floating-point numbers and tests whether they are the same up to three decimal places.
5. Write a Java program to find the number of days in a month.
6. Write a Java program that takes a year from the user and prints whether it is a leap year or not.
7. Write a program to check even or odd number.
8. Write a program to print valid to vote if age greater than or equal to 18 else print not valid to vote.
9. Write a program to print maximum among two integer numbers.
10. Write a program to print square of maximum and cube of minimum number.
SOOPRO Pathshala Exercises
1. Write a program to print diff of max and min among three numbers.
2. Write a program to print grade of student marks.
3. Write a program to print both are equal no, if two numbers are equal else print not equal.
4. Write a program to print 1 if two integer numbers are same, else print 0.
5. Write a program to print smallest among three numbers.
6. Write a program to print addition of two numbers on choice 1, subtraction of two numbers on choice 2, multiplication of two numbers on choice3 and division of two numbers on choice 4.
7. Write a program to print area of circle on choice 1, area of rectangle on choice 2, area of traingle on choice 3, invalid choice on choice 4.
8. Write a program to print sum of square and cube of any even number.
9. Write a program to print diff of square and cube of any odd number.
10. Write a program to print product of square and cube of even number
SOOPRO Pathshala Exercises
1. Write a program to print 1 to 10 using for loop.
2. Write a program to print 10 to 1 using for loop.
3. Write a program to print 20 to 50 using for loop.
4. Write a program to print sum of 1 to 10 using for loop.
5. Write a program to print square of 1 to 10 using for loop.
6. Write a program to print cube of 1 to 10 using for loop.
7. Write a program to print even sum and odd sum of 1 to 10.
8. write a program to print table of any number using for loop.
9. Write a program to calculate the sum of first 10 natural number.
10. Write a program that prompts the user to input a positive integer. It should then print the multiplication table of that number.
11. Write a program to find the factorial value of any number entered through the keyboard.
12. Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.
13. Write a program that prompts the user to input an integer and then outputs the number with the digits reversed. For example, if the input is 12345, the output should be 54321.
14. Write a program that reads a set of integers, and then prints the sum of the even and odd integers.
15. Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number.
16. Write a program to calculate HCF of Two given number.
17. Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate.
18. Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered.
19. Write a program to enter the numbers till the user wants and at the end the program should display the largest and smallest numbers entered.
20. Write a program to print out all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number.
SOOPRO Pathshala Exercises
1. Write a java program to print prime numbers between 2 to 50.
2. Write a java program to print not prime numbers between 2 to 10.
3. Write a java program to print your name ten times using while loop.
4. Write a java program to print vowels and consonants of your first name.
5. Write a java program to print vowels in left side and consonants in right side.
6. Write a java program to print square of all odd numbers of 1 to 10.
7. Write a java program to print cube of all even numbers of 1 to 10.
8. Write a java program to print average of 1 to 10.
9. Write a program to print sum of table of any number.
10. Write a program to print sum of table of 1 to 5.
11. Write a program to print table of only even numbers between 5 to 20.
12. Write a program to print table of only odd numbers between 2 to 20.
13. Write a program to print total table sum between 1 to 10.
14. Write a program to print all even numbers between 2 to 50 in left side and all odd numbers in right side.
15. Write a program to print reverse of any three digit numbers.
16. Write a program to print sum of first and last number of any four digit numbers.
17. Write a program to print subtract of first and last number of any five digit numbers.
18. Write a program to print product of max and min of any four digit numbers.
19. Write a program to check whether given number is palindrome or not.
20. Write a program to check armstrong number.
21. Write a program to print table of max of and factorial of min of any five digit numbers.
22. Write a program to print sum of max and min and average of all three digit numbers.
23. Write a program to print following :
*
**
***
****
*****
24. Write a program to print table of any number in horizontal form.
25. Write a program to print square of all odd numbers in vertical form
26. Write a program to print factorial of 1 to 5.
27. Write a program to print factorial sum of all odd numbers between 1 to 10.
28. Write a program to print prime sum of odd even numbers between 5 to 50.
SOOPRO Pathshala Exercises
1. Create a single dimensional array.
2. Write a program to create single dimensional array and store values in it using user input.
3. Write a program to create single dimensional array of int type.
4. Write a program to create single dimensional array of char type.
5. Write a program to create float array of single dimensional array.
6. Write a program to create single dimensional array of double type.
7. Write a program to create single dimensional array of long type.
8. Write a program to create single dimensional array of string type.
9. Write a program to print sum of all elements of int array.
10. Write a program to print sum of all elements of long array.
11. Write a program to print sum of all elements of float array.
12. Write a program to print sum of all elements of float array.
13. Write a program to print even and odd of integer array.
14. Write a program to print square of integer array.
15. Write a program to print square of float array.
16. Write a program to print square of double array.
17. Write a program to print square of long array.
18. Write a program to print evensum and oddsum of int array.
19. Write a program to print square of even number and cube of odd number of array.
20. Write a program to print average of array.
21. Write a program to print sum and average of only even numbres in array.
22. Write a program to print multiplication of odd numbers of single dimensional array.
23. Write a program to print maximum of array.
24. Write a program to print sum and multiplication of odd numbers of single dimensional array.
25. Write a program to print minimum of array.
SOOPRO Pathshala Exercises
1. Write a program to print maximum and minimum of single dimensional array.
2. Write a program to print 2nd maximum number of array.
3. Write a program to print 2nd minimum number of array.
4. Write a program to print square of maximum of single dimensional array.
5. Write a program to print cube of minimum of single dimensional array.
6. Write a program to copy integer array.
7. Write a program to copy string array.
8. Write a program to copy float array.
9. Write a program to copy long array.
10. Write a program to print sum and average of only odd numbers of array.
11. Write a program to pass integer array to function.
12. Write a program to pass float array to function.
13. Write a program to pass long array to function.
14. Write a program to print sum of long array.
15. Write a program to return total sum of avg and sum of single dimensional array.
16. Write a program to return maximum of array.
17. Write a program to return minimum of array.
18. Write a program to return diff of maximum and minimum of array.
19. Write a program to return avg of even numbers of array.
20. Write a program to return sum of odd numbers of array.
21. Write a program to check prime and not prime of array.
22. Write a program to print primesum and not prime sum of array.
23. Write a program to return array.
24. Write a program to pass and return integer array.
25. Write a program to pass and return float array.
SOOPRO Pathshala Exercises
1. Write a program to pass and return double array.
2. Write a program to pass and return char array.
3. Write a program to pass and return long array.
4. Write a program to print reverse of string array.
5. Write a program to print sum of first value and last value of array.
6. Write a program to print factorial of array.
7. Write a program to print factorial of max and min of array.
8. Write a program to print factorial of diff of max and min of array.
9. Write a program to print table of array.
10. Write a program to print table sum of array.
11. Write a program to print table sum of array.
12. Write a program to create multi dimensional array.
13. Write a program to print first row of multi dimensional array.
14. Write a program to print second row of multi dimensional array.
15. Write a program to print third row of multi dimensional array.
16. Write a program to print table of first row of multi dimensional array.
17. Write a program to print table of last column of multi dimensional array.
18. Write a program to pass multi dimensional array to method.
19. Write a program to pass and return matrix.
20. Write a program to pass string matrix and print second row of matrix.
21. Write a program to pass char matrix and print second column of matrix.
22. Write a program to pass float matrix and return avg of third row of matrix.
23. Write a program to print array elements in ascending order
24. Write a program to print array elements in descending order.
25. Write a program to print square of second maximum and cube of third minimum of single d array.
SOOPRO Pathshala Exercises
1. Write a program to show the simple structure of a function.
2. Write a program to find the square of any number using the function.
3. Write a program to swap two numbers using a function.
4. Write a program to check if a given number is even or odd using the function.
5. Write a program to check whether a number is a prime number or not using the function.
6. Write a program to get the largest element of an array using the function.
7. Write a program to check Armstrong and Perfect numbers using the function.
8. Write a program to print table of any number using function.
9. Write a program to print sum of any table using function.
10. Write a program to compare string value using function.
SOOPRO Pathshala Exercises
1. Write a program to find the maximum and minimum of some values using a function that returns an array.
2. Write a program to print the square of array elements using callback function.
3. Write a program to find cube of any number using function.
4. Write a program to find diameter, circumference and area of circle using functions
5. Write a program to find maximum and minimum between two numbers using functions.
6. Write a program to check whether a number is even or odd using functions.
7. Write a program to check whether a number is prime, Armstrong or perfect number using functions.
8. Write a program to find all prime numbers between given interval using functions.
9. Write a program to print all strong numbers between given interval using functions.
10. Write a program to print all Armstrong numbers between given interval using functions.
SOOPRO Pathshala Exercises
1. Write a program to print all perfect numbers between given interval using functions.
2. Write a program to find power of any number using recursion.
3. Write a program to print all natural numbers between 1 to n using recursion.
4. Write a program to print all even or odd numbers in given range using recursion.
5. Write a program to find sum of all natural numbers between 1 to n using recursion.
6. Write a program to find sum of all even or odd numbers in given range using recursion.
7. Write a program to find reverse of any number using recursion.
8. Write a program to check whether a number is palindrome or not using recursion.
9. Write a program to find sum of digits of a given number using recursion.
10. Write a program to find factorial of any number using recursion.
SOOPRO Pathshala Exercises
1. Write a program to generate nth Fibonacci term using recursion.
2. Write a program to find GCD (HCF) of two numbers using recursion.
3. Write a program to find LCM of two numbers using recursion.
4. Write a program to display all array elements using recursion.
5. Write a program to find sum of elements of array using recursion.