0% found this document useful (0 votes)
45 views1 page

23. Functions Questions

Uploaded by

someshgondal2
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)
45 views1 page

23. Functions Questions

Uploaded by

someshgondal2
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/ 1

FUNCTIONS QUESTIONS

Question 1 : Write a Java method to compute the average of three numbers..

Question 2 : Write a method named isEven that accepts an int argument. The method
should return true if the argument is even, or false otherwise. Also write a program to test
your method.

Question 3 : Write a Java program to check if a number is a palindrome in Java? ( 121 is


a palindrome, 321 is not)
A number is called a palindrome if the number is equal to the reverse of a number e.g., 121 is
a palindrome because the reverse of 121 is 121 itself. On the other hand, 321 is not a
palindrome because the reverse of 321 is 123, which is not equal to 321.

Question 4 : READ & CODE EXERCISE


Search about(Google) & use the following methods of the Math class in Java:
a. Math.min( )
b. Math.max( )
c. Math.sqrt( )
d. Math.pow( )
e. Math.avg( )
f. Math.abs( )

Free reading resource (https://www.javatpoint.com/java-math)


Please feel free to look for more resources/websites on your own.

Question 5 :
Write a Java method to compute the sum of the digits in an integer.

(Hint : Approach this question in the following way :


a. Take a variable sum = 0
b. Find the last digit of the number
c. Add it to the sum
d. Repeat a & b until the number becomes 0 )

https://t.me/+QGUyTripaP4zNTcx
https://telegram.me/+QGUyTripaP4zNTcx

You might also like