0% found this document useful (0 votes)
1 views

Functions Questions

The document contains a series of programming questions focused on Java methods, including computing the average of three numbers, checking if a number is even, determining if a number is a palindrome, and utilizing various Math class methods. Additionally, it includes a task to compute the sum of the digits in an integer with a hint on how to approach the problem. Resources for further reading are also provided.

Uploaded by

Suyash Jaiswal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Functions Questions

The document contains a series of programming questions focused on Java methods, including computing the average of three numbers, checking if a number is even, determining if a number is a palindrome, and utilizing various Math class methods. Additionally, it includes a task to compute the sum of the digits in an integer with a hint on how to approach the problem. Resources for further reading are also provided.

Uploaded by

Suyash Jaiswal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

FUNCTIONS QUESTIONS

[email protected]
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 )

You might also like