Q)When to use for loop and when to use while loop? =>There is no hard and fast rule to use a particular loop statement to solve a problem that involves repetetion. We can use any one of them. But coding convenience has to be taken into consideration. =>If the number of iterations if we know in advance, better go for for loop. If not, go for while loop. Q)Java program to display the multiplication table of user's choice upto 10 multiples. //MultiplicationTable.java import java.util.Scanner; class MultiplicationTable{ public static void main(String args[]){ Scanner scanner=new Scanner(System.in); System.out.print("Which multiplication table to print?"); int table=scanner.nextInt(); for(int i=1;i<=10;i++) { System.out.println(table+"X"+i+"="+(table*i)); }//for }//main }//class Q)Java program to find the sum of the digits of a number. //SumOfDigits.java import java.util.Scanner; class SumOfDigits{ public static void main(String args[]){ Scanner scanner=new Scanner(System.in); System.out.print("Enter the number:"); int n=scanner.nextInt();//234 int sum=0;//to hold the sum of the digits while(n>0){ sum=sum+n%10; n=n/10; } System.out.println("The sum of the digits is "+sum); }//main }//class OR import java.util.Scanner; class SumOfDigits{ public static void main(String args[]){ Scanner scanner=new Scanner(System.in); System.out.print("Enter the number:"); int n=scanner.nextInt();//234 int temp=n;//to maintain another copy of n int sum=0;//to hold the sum of the digits while(n>0){ sum=sum+n%10; n=n/10; } System.out.println("The sum of the digits of "+temp+" is "+sum); }//main }//class Q)Java program to find if a number is a palindrome. 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();//234 int temp=n;//to maintain another copy of n int reverse=0;//to hold the sum of the digits 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 plaindrome"); } }//main }//class Q)What is the output of the following program? import java.util.Scanner; 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); } } }//main }//class Ans:- 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 Note:- For each iteration of outer loop, all the iterations of inner loop will be completed