(iii) The following functions are a part of some class:

void Try(char ch[],int x)
{ 
System.out.println(ch); char temp;
if ( x< ch.length/2)
{ 
temp=ch[x];
ch[x]= ch[ch.length-x-1];
ch[ch.length-x-1] = temp;
Try(ch,x+1);
} 
}
void Try1(String n)
{ 
char c[]=new char[n.length()];
for(int i=0;i< c.length;i++)
c[i] = n.charAt(i);
Try(c,0);
}
(a) What will the output of Try( ) when the value of ch[]={'P','L','A','Y'} and x=1?
(b) What will the output of Try1( ) when the value of n="SKY"?


Solution



(a)
PLAY
PALY

(b)
SKY
YKS


Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com