PrepAway - Latest Free Exam Questions & Answers

Which three code fragments will display "Hello" followed by a new line?

You want to insert a new line on the console. Which three code fragments will display “Hello”
followed by a new line? (Each correct answer presents a complete solution. Choose three.)

PrepAway - Latest Free Exam Questions & Answers

A.
Console.Write(“Hello\t”) ;

B.
Console.Write(“Hello\n”);

C.
Console.Error.Write(“Hello\t”);

D.
Console.Error.WriteLine (“Hello”) ;

E.
Console.WriteLine(“Hello”);

Explanation:
B: \n adds a newline.
D: Console.Error.WriteLine writes a newline.
E: Console.WriteLine writes a newline.
Incorrect:
A, C: \t is just a space

One Comment on “Which three code fragments will display "Hello" followed by a new line?


Leave a Reply