Convert the following iterative method to one that uses recursion: public static
ID: 3836120 • Letter: C
Question
Convert the following iterative method to one that uses recursion: public static void sign(int n) {while (n > 0) {System.out.println("No Parking"); n--;}} The following statement creates an ArrayList object. What is the purpose of the notation? ArrayList arr = new ArrayList (); a It specifies that only String objects may be stored in the ArrayList object. B It specifies that the get method will return only String objects. C It specifies that String objects may not be stored in the ArrayList object. d It specifies that everything stored in the ArrayList object will be converted to a String.Explanation / Answer
Program :
import java.util.*;
import java.io.*;
class Main{
public static void sign(int n){
if(n>0){
System.out.println("No Parking");
sign(n-1);
}
}
public static void main(String args[]) throws Exception{
sign(5);
}
}
OUTPUT :
No Parking
No Parking
No Parking
No Parking
No Parking
2. Answer is a. It specifies that the String type objects should be stored in the arrayList