Java OCA OCP Practice Question 1600

Question

Which line will print the string "MUM"?

public class Main{
    public static void main (String args  []){
        String s = "MINIMUM";
        System.out.println (s.substring (4, 7)); //1
        System.out.println (s.substring (5)); //2
        System.out.println (s.substring (s.indexOf ('I', 3))); //3
        System.out.println (s.substring (s.indexOf ('I', 4))); //4
     }
}

Select 1 option

  • A. 1
  • B. 2
  • C. 3
  • D. 4
  • E. None of these.


Correct Option is  : A

Note

You should know how substring and indexOf methods of String class work.




PreviousNext

Related