41.
String str1 = "Kolkata".replace('k', 'a');

In the above statement, the effect on string Kolkata is

43.
What will be the output?
public class Test{ 
        public static void main (String[] args){ 
		String test = "a1b2c3"; 
                String[] tokens = test.split("\\d"); 
                for(String s: tokens) 
                        System.out.print(s); 
	} 
}

44.
How many objects will be created?
String a = new String("Examveda");
String b = new String("Examveda");
String c = "Examveda";
String d = "Examveda";

46.
What will be output?
String S1 = "S1 ="+ "123"+"456";
String S2 = "S2 ="+(123+456);

47.
What will be the output of the following program code?
public class Test{
      public static void main(String args[]){
            String s = "what";
            StringBuffer sb = new StringBuffer("what");
            System.out.print(sb.equals(s)+","+s.equals(sb));
      }
}

48.
What will be the output?
public class Test{
     public static void main(String args[]){
           Object myObj = new String[]{"one", "two", "three"};
           {
          for(String s : (String[])myObj) 
	        System.out.print(s + ".");
         }
     }
}

49.
Determine output:
public class Test{
      public static void main(String args[]){
            String str = null;
            if(str.length() == 0){
                  System.out.print("1");
            }
            else if(str == null){
                  System.out.print("2");
            }
            else{
                  System.out.print("3");
            }
      }
}

Read More Section(Strings)

Each Section contains maximum 100 MCQs question on Strings. To get more questions visit other sections.