10/01/25 ----------- Q)Java program to find if a number is a palindrome. //Palindrome.java import java.util.Scanner; class Palindrome{ public static void main(String args[]){ Scanner scanner=new Scanner(System.in); System.out.print("Enter the number:"); int n=scanner.nextInt();//232 int temp=n;//one more copy maintaining int reverse=0; while(n!=0){ reverse=reverse*10+n%10; n=n/10; } if(temp==reverse){ System.out.println("It is a palindrome"); } else{ System.out.println("It is not a palindrome"); } } } Q)What is the output of the following program? class Break{ public static void main(String args[]){ for(int i=1;i<=10;i++){ System.out.println(i); if (i==4){ break; }//if }//for }//main }//class Ans: 1 2 3 4 Q)What is the output of the following program. class Continue{ public static void main(String args[]){ for(int i=1;i<=5;i++){ if (i==4){ continue; }//if System.out.println(i); }//for }//main }//class Ans: 1 2 3 5 Q)Explain about nested for loop. =>Writing a for loop within the body of another for loop is known as nesting of "for loop". For eg for(int i=1;i<=3;i++) { for(int j=1;j<=10;j++){ System.out.println(i+"\t"+j); }//inner for loop/nested for loop }//outer for loop. =>For every iteration of outer for loop, all the iterations of inner for loop will be completely executed. Q)What is the output of the following program? class NestedLoop{ public static void main(String args[]){ for(int i=1;i<4;i++){ for(int j=1;j<=3;j++){ System.out.println(i+" "+j); }//inner for loop }//outer for loop }//main }//class Ans:- 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3