Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2.) if string str = \"Grand Canyon\", then what is the value of str.substring (7

ID: 3874295 • Letter: 2

Question

2.) if string str = "Grand Canyon", then what is the value of str.substring (7);?
A. Canyon
B. anyon
C. nyon
D. Grand C
E. and Canyon

3.) Consider the following method total below.
     public static into total (int result, int a, int b)

{
         if (a==0)

         {
        
         if (b==0)
      
         {
         
         return result * 2;

         }

         return result /2;

         }

         else

         {

         return result *3;

         }

}

The assignment statement
x=total (1,0,1);
must result in

A. x being assigned the value 3
B. x being assigned the value 7
C. x being assigned the value 5
D. x being assigned the value 2
E. x being assigned the value 0

4. Consider the method total below.
    public static int total (int result, int a, int b)

     {
               if (a==0)
               {
                          if (b==0)
                          {
                                    return result *2;
                          }
                          return result /2;
               }
               else
              {
                          return result *3;
              }
      }
The assignment statement
x=total (5,0,0);
must result in

A. x being assigned the value 4
B. x being assigned the value 8
C. x being assigned the value 5
D. x being assigned the value 2
E. x being assigned the value 10

Explanation / Answer

1. if string str = "Grand Canyon", then what is the value of str.substring (7);-----B) anyon

substring method skips characters until given index and gives rest of characters.

2.x=total (1,0,1)------E) x being assigned the value 0

result (1)/2=0.5 but return type is integer ,So total function return 0.

3.   x=total (5,0,0)-------E) x being assigned the value 10

result (5)*2=10; return type is integer and 10 is also an integer.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote