Which of the following statements contains an error?
1. system.out.print("/tab Age in Minutes: " + ageInMinutes +"/n");
2. system.out.print("t/ Age in Minutes: " + ageInMinutes + "n/");
3. system.out.print("/t Age in Minutes: " + ageInMinutes + "/n");
a. 1 only
b. 2 only
c. 3 only
d. 1 and 2 only
e. 2 and 3 only
I thought my best answer is A is that correct
nope. "t/" and "n/" are also an errors
ohh so 1 and 2 are both errors
yep
actually, #1 is syntactically correct, but will print
ab Age in Minutes: ...
Which of the following statements does not contain an error?
1. string firstName= in.next();
2. string lastName= in.nextline();
3. system.out.print("\n");
a. 1 only
b. 2 only
c. 3 only
d. 1 and 3 only
e. 2 and 3 only
is the answer 1 and 3
Yes, your answer is correct. The statement containing an error is option 1, which is:
1. system.out.print("/tab Age in Minutes: " + ageInMinutes +"/n");
The error in this statement is the use of "/tab" instead of "\t" to represent a tab character. The correct escape sequence for a tab character in Java is "\t". So, the correct statement should be:
1. system.out.print("\tAge in Minutes: " + ageInMinutes + "\n");
Option 2 and 3 do not contain any errors in regards to the use of escape sequences.