Wednesday, 11 March 2015

[JAVA] [ICSE 2006 Answer 6] Replacing Words

Question:
ICSE 2006 Question 6
Consider the following statement-
"January 26 is celebrated as the Republic Day of India".
Write a program to change 26 to 15, January to August, Republic to Independence and finally print "August 15 is celebrated as the Independence Day of India".

Source Code:
public class ICSE2006_6
{
    public static void main()throws Exception
    {
        String s="January 26 is celebrated as the Republic Day of India";
        s=s.replace("January", "August");
        s=s.replace("26", "15");
        s=s.replace("Republic", "Independence");
        System.out.println(s);
    }
}


Result:
OUTPUT:
August 15 is celebrated as the Independence Day of India

7 comments:

  1. Abe abhi tumko ye nhi pta hai kishi "replace" ka use string me like class 10 me scope me nhi hai.

    ReplyDelete
  2. Abe abhi tumko ye nhi pta hai kishi "replace" ka use string me like class 10 me scope me nhi hai.

    ReplyDelete
  3. Thank you so much it really helped me alot

    ReplyDelete
  4. Don't fool the students your answers are useless it is absolutely wrong

    ReplyDelete
  5. Thank you for the answers... But I have not used any exception handlers in my program.... I have done the programs without the use of exception handers..... But though thank you it helped me...

    ReplyDelete