Computer Science, asked by bhageerath156, 1 year ago

Initialize two character variables in a program and display the characters in alphabetical order.

Answers

Answered by ankurbadani84
8

Answer:

Explanation:

class ABC

{

   public static void main (String[] args)  

   {

       char item1='x';

       char item2='y';

       if (item1>item2)

           System.out.println(item2+" , "+item1);

       

       else

           System.out.println(item1+" , "+item2);

   }

   }

if first character is s and second is e then output will be e,s.

if first character is a and second is e then output will be a,e

Answered by Keshavtiwari896
1

Answer:

class ABCD

{

   public static void main (String[] args)

   {

       char item1='a';

       char item2='b';

       if (item1>item2)

           System.out.println(item2+" , "+item1);

       

       else

           System.out.println(item1+" , "+item2);

   }

   }

Explanation:

Similar questions