You are on page 1of 4

Practice Questions

1. Write a Java method to find the smallest number among two numbers.

2. Write a Java method to compute the average of three numbers.


3. Write a Java method to display the middle character of a string.
Note: a) If the length of the string is even there will be two middle characters.
b) If the length of the string is odd there will be one middle character.

4. Write a Java method to compute the sum of the digits in an integer.


Input a number: 52
Sum of digits: 7 (i.e. 5+2)
5. Write a Java program to compute the square root of any
given integer.
Input a positive integer: 25
Square root of 25 is: 5

THE END

You might also like