Is the code snippet written below legal?
String s = "1234";
For (int i = 0; i <= 5; i++)
{
System.out.print) ;
}
A) Yes.
B) No; there should be a semicolon at the end of line 2.
C) No; for i = 3, s.substring(i, i + 1) will result in an StringIndexOutOfBounds error.
D) No; line 4 should have no semicolon at the end.
Correct Answer:
Verified
Q21: What is the output of the code
Q45: Which statement about this code snippet is
Q62: How many times is the text "Let's
Q71: How many times does the following loop
Q85: Which statement is correct about the execution
Q87: Is the following code snippet legal?
Boolean b
Q88: What will be the output of the
Q91: How many times does the following loop
Q93: What will be the output of the
Q95: What is the last output line of
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents