Java

JAVA STRING CODING INTERVIEW QUESTIONS||JAVA STRING PROGRAMMING INTERVIEW QUESTIONS

  Write  a  Java  Program  to   check   the  given  String  is  Palindrome  or  not     Write  a  Java  Program  to  Reverse  a  String     Write  a  Java  Program  to  Check  if  the  given   two  Strings   are   Anagram  or  not     JAVA  PROGRAM  TO  PRINT  ALL  THE  DUPLICATE   CHARACTERS   IN  A  STRING   […]

JAVA STRING CODING INTERVIEW QUESTIONS||JAVA STRING PROGRAMMING INTERVIEW QUESTIONS Read More »

JAVA PROGRAM TO CHECK WHEATHER A NUMBER IS PALINDROME NUMBER OR NOT

        A  number  is  called  Palindrome  number   if  the  reverse  of  the  given  number  is  same  as   that  of  a  given  number .   Example :   Input :n= 121 Output : Reverse  of   n=121   This  Number  121  is  a  Palindrome  Number   Input:  n=885 Output : Reverse  of  n=588 This 

JAVA PROGRAM TO CHECK WHEATHER A NUMBER IS PALINDROME NUMBER OR NOT Read More »

JAVA PROGRAM TO PRINT ALL THE DUPLICATE CHARACTERS IN A STRING

    A  String  s  is  given ,  identify  all  the  characters   that  appear  more  than  once  and  print  those  characters  along  with  it’s  count  of  each.   Examples:   Input : s=”happymindhappylife”;   Output :    h 2     a 2      p  4       y  2       i   2  

JAVA PROGRAM TO PRINT ALL THE DUPLICATE CHARACTERS IN A STRING Read More »

JAVA PROGRAM TO CHECK WHEATHER A GIVEN YEAR IS LEAP YEAR OR NOT

    A  Year  is  called  Leap  Year  which   contains  366  days , which  comes   once  every  four  years .   A  Leap  year  contains  366  days  and  occur  in  every  4  years. A  century  year  (which  is  ending  with 00 )  is  a  Leap  year  only  if  it  is  divisible  by  400. A  non 

JAVA PROGRAM TO CHECK WHEATHER A GIVEN YEAR IS LEAP YEAR OR NOT Read More »

JAVA PROGRAM TO PRINT 1 TO 100 WITHOUT LOOP

          Approach:   Using  Recursion      public  class   PrintNumbers{    static  void   printNumbers(int  initial , int  last ) {        if(initial<=last){           System.out.println(initial+” ” );             printNumbers(initial+1,last);     }   }   public  static   void  main(String  args[]) {

JAVA PROGRAM TO PRINT 1 TO 100 WITHOUT LOOP Read More »

Java Program to Find the Sum of First N Odd & Even Numbers

  Numbers  which  are  divisible  by  2  are  called  even  numbers (ending  with  0 ,2,4,6,8 ),  while  numbers  that  are  not  divisible  by  2  are  called  odd  numbers (ending  with 1, 3,5,7,9 )      Example : 9    Output :   Sum  of  First  9  Even  Numbers = 2+4+6+8+10+12+14+16+18=90  Sum  of  First  9  Odd 

Java Program to Find the Sum of First N Odd & Even Numbers Read More »

JAVA PROGRAM TO CALCULATE THE SUM OF ODD NUMBERS

  Numbers  that  are   divisible  by  2  are  called  Even  numbers(ending  with 0,2,4,6,8), while  numbers  that  are  not  divisible  by  2  are  called  odd  numbers(which  are  ending  with  1,3,5,7,9)     Example:   Input: 5 Output:     Sum  of   Odd  Numbers present  from number  1  to  5 =1+3+5=9 Sum  of  Even  Numbers  present  from 

JAVA PROGRAM TO CALCULATE THE SUM OF ODD NUMBERS Read More »

JAVA PROGRAM TO FIND THE FACTORIAL OF A NUMBER

  The  factorial   of  a   number   is    the   multiplication  of  all  positive  integers  from  1   to  that  number .      Factorial  of  number  n   is  represented  as  n!         Formula  for  Factorial :     n!=n*(n-1)*(n-2)*(n-3)*……………*1   Example :  5!=5*4*3*2*1=120 6!=6*5*4*3*2*1=720           Iterative  Approach :  

JAVA PROGRAM TO FIND THE FACTORIAL OF A NUMBER Read More »

JAVA PROGRAM TO FIND THE SUM OF THE DIGITS OF A NUMBER

  Example :  Input: 987 Output: 9+8+7=24     Java program   public  class  SumofDigits {          public  static   void   main(String  args[] ) {          int  num, digit,sum=0;          Scanner  sc=new  Scanner(System.in);          System.out.println(“Enter  a  number “);          int   num=sc.nextInt();

JAVA PROGRAM TO FIND THE SUM OF THE DIGITS OF A NUMBER Read More »

JAVA PROGRAM TO PRINT THE PRIME NUMBERS FROM 1 TO N.

            A  prime  number  is  a  whole  number greater  than  1  which  is  only  divisible  by  1  &  the  number  itself i.e. A  prime  number  can’t  be  divided  by  other  numbers  except  1  &  the  number   itself.   e.g. 2,3,5,7,11,13,17,19 …..etc.       Approach : According  to  definition, number

JAVA PROGRAM TO PRINT THE PRIME NUMBERS FROM 1 TO N. Read More »