CHAPTER5
CHAPTER5
9. When a method has been declared more than once in a class, how does Java determine the
overloading?
Ans. When a method has been declared more than once in a class, then java puts different signatures to
determine overloading.
www.bhuvantechs.com
14. A palindromic prime is a prime number and also palindromic. For example, 131, 313, and 757 are
prime numbers and also palindromic prime numbers. Write a program that displays the first 100
palindromic prime numbers.
Ans. import java.util.*;
public class PalindromicPrime
{
public static boolean Prime(int num)
{
int count = 0;
for(int divisor=2;divisor<=num/2;divisor++)
{
if(num%divisor==0)
{
return false; // if the number is not prime return false.
}
}
return true; // if the number is prime return true.
}
public static boolean Palindromic(int num)
{
int result = 0;
www.bhuvantechs.com
Invoking an impure method causes side effects. Impure methods may or may not return a value.