Question: Consider the following functions: void foo ( int length ) { foo ( length , ) ; } void foo ( int length,

Consider the following functions:
void foo ( int length ){
foo (length,"");
}
void foo ( int length, String seq ){
if (seq.length()== length ){
System.out.printf("%s
", seq );
return;
}
if (seq.length()!=0){
String seq0= seq +"0";
foo( length, seq0);
}
String seq1= seq +"1";
foo( length, seq1);
}
What is the last string that is printed when we call foo(4)?
0000
0001
1000
1111
1110
0111
none of the above
Consider the following functions: void foo ( int

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!