What is "missing part" in the piece of code below to produce the following output
012345
12345
2345
345
45
5
String base = "012345";
int count = 0;
while (count <= 5)
{
String tmp = ______________;
System.out.println(tmp);
count++;
}
a) base.substring(count,6)
b) base.substring(1,count+1)
c) base.substring(0, count)
D)base.substring(count+1)
e) base.substring(count)
Given code:
public class Missing {
public static void main(String[] args) {
String base = "012345";
int count = 0;
while(count <= 5) {
String tmp =
------------------------;
System.out.println(tmp);
count++;
}
}
}
Options:
a) base.substring(count,6)
b) base.substring(1,count+1)
c) base.substring(0, count)
D)base.substring(count+1)
e) base.substring(count)
Answer: Option (a) and (e) gives the same result.
CODE:
public class Missing {
public static void main(String[] args) {
String base = "012345";
int count = 0;
while(count <= 5) {
String tmp =
base.substring(count,6);
System.out.println(tmp);
count++;
}
}
}
SCREENSHOT OF THE CODE:
OUTPUT:
CODE:
public class Missing {
public static void main(String[] args) {
String base = "012345";
int count = 0;
while(count <= 5) {
String tmp =
base.substring(count);
System.out.println(tmp);
count++;
}
}
}
SCREENSHOT OF THE CODE:
OUTPUT:
Thank you.
Get Answers For Free
Most questions answered within 1 hours.