Computer Science, asked by kandikiran0831, 10 months ago

Write the output:
      char ch=’F’;
       int m=ch;
       m=m+2;
       System.out.println(m+”\t”+ch);

Answers

Answered by poojan
6

Answer:

72 F

Program:

public class something

{

    public static void main(String []args)

   {

        char ch='F';

        int m=ch;

        m=m+2;

        System.out.println(m+"\t"+ch);

    }

}

Output:

72 F

Explanation:

As the character 'F' is stored in the variable ch, On assigning ch to m as an integer, the ASCII value of the character that is stored in the variable ch will be stored in m. As the ASCII value of F is 70, variable m is assigned with the value 70.

As now, the value of m is 70, in the next statemnt, on adding 2 to the value in m, the variable m gets 72 into in's memory.

So, finally, 72 tab space  F will be printed as, 72 F.

Please look at the attachment given below to see how the program is compiled.

Cheers!!!

Attachments:
Similar questions