Computer Applications
Give output of the following method definition and also write the mathematical operation they carry out:
void test3(char c)
{
System.out.println( (int) c);
}
if 'm' is passed to c.
Java
User Defined Methods
134 Likes
Answer
109
Working
This method prints the ASCII code of its argument. When 'm' is passed to this method, its ASCII code which is 109 gets printed as the output.
Answered By
69 Likes
Related Questions
Give output of the following method definition and also write the mathematical operation they carry out:
void test2(int a, int b) { while( a != b) { if ( a > b) a = a — b; else a = b — a; } System.out.println(a); }
if 4 and 17 are passed to the function.
Give output of the following method definition and also write the mathematical operation they carry out:
void test1(int n) { for(int x=1; x<=n; x++) if(n%x == 0) System. out.println(x); }
if 12 is passed to n.
Give output of the following method definition and also write the mathematical operation they carry out:
void test4(String x, String y) { if(x.compareTo(y) > 0) System.out.println(x); else System.out.println(y); }
if "AMIT" and "AMAN" are passed to the method.