This question refers to the getString method shown below pub

This question refers to the getString method shown below: public static String getString(String s1, String s2) {int index = s1.index0f(s2); return s1.substring(index, index + s2.length());} Which is true about getString? It may return a string that Is equal to s2. Has no characters in common with s2. Is equal to s1. I and III only II and III only I and II only I, II, and III None is true.

Solution

import java.lang.String;
public class UseCourse
{
   public static void main(String[] args)
   {
      String s1= \"helloworld\";
      String s2= \"hello\";
// }
      // public static String getString(String s11 , String s21)
      // {
           int index = s1.indexOf(s2);
           System.out.println(s1.substring(index, index + s2.length()));
         
           //return;
       }
  
   output for above program is hello

answer is C

is equal to s2 and has no characters in common with s2

output depend upon string value of s2

 This question refers to the getString method shown below: public static String getString(String s1, String s2) {int index = s1.index0f(s2); return s1.substring

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site