To successfully complete this course and move on to writing programs that communicate over networks, you should be comfortable with
- classes, objects, and methods in Java, particularly constructors and
toString()
methods
- input and output streams
- writing character-mode Java applications with
main()
methods
- the basics of the AWT including windows, dialog boxes, and Java 1.1 event handling
This course builds on the skills you learned in the first
Networking with Java course,
Java Streams.
If you did not take that course, you should still be able to successfully complete
Java Readers and Writers as long as you have the prerequisite skills listed above.
The following quiz question, tests your knowledge of the Java Console class.
Which of the following statements can cause "hello" to be printed to the console? [Please select 1 option:]
- System.console().println("hello");
- System.console().writer().println("hello");
- System.console().message("hello");
- System.console().out("hello");
Choice B is correct. The
writer()
method of the Console class returns the unique PrintWriter object associated with this console.
The
println()
method of the PrintWriter class can then be called to print to the console.
Choices A, C and D are incorrect because the Console class does not define 1) println, 2) message and 3) out methods.
The correct answer is:
System.console().writer().println("hello");