Consider the following method, which is intended to count th…

Consider the following method, which is intended to count the number of times the letter “A” appears in the string str. public static int countA(String str) { int count = 0;   while (str.length() > 0) { int pos = str.indexOf(“A”); if (pos >= 0) { count++; /* missing code */ } else { return count; } } return count; } Which of the following should be used to replace /* missing code */ so that method countA will work as intended?

Consider the following code segments.     I.   int k = 1;  …

Consider the following code segments.     I.   int k = 1;     while (k < 20)     {       if (k % 3 == 1)         System.out.print( k + " ");         k = k + 3;     }      II.   for (int k = 1; k < 20; k++)     {       if (k % 3 == 1)         System.out.print( k + " ");     }      III.  for (int k = 1; k < 20; k = k + 3)     {       System.out.print( k + " ");     }   Which of the code segments above will produce the following output?     1 4 7 10 13 16 19

The following method is intended to print the number of digi…

The following method is intended to print the number of digits in the parameter num. public int numDigits(int num) { int count = 0; while (/* missing condition */) { count++; num = num / 10; } return count; } Which of the following can be used to replace /* missing condition */ so that the method will work as intended?