Java Basics - Quiz Explanation
The answers you selected are indicated below, along with text that explains the correct answers.
1.
Which of the following methods forms the heart of a Java application and is called by the Java interpreter to actually run the application?
Please select the best answer.
A.
begin()
B.
init()
C.
main()
The correct answer is C.
The
main()
method forms the heart of a Java application and is called by the Java interpreter to actually run the application. There is no method named
begin()
in the Java API that is associated with applications. The
init()
method is used to initialize applets and plays no role in applications.
2.
Information entered on the command-line when you execute an application is referred to as:
Please select the best answer.
A.
Application initialization data
B.
Command-line arguments
C.
Application parameters
The correct answer is B.
Information entered on the command-line when you execute an application is referred to as command-line arguments. Although "application initialization data" and "application parameters" might accurately describe information entered on the command-line of an application, "command-line arguments" is the correct name of the information.
3.
Which one of the following devices is typically associated with the
System.in
object?
Please select the best answer.
A.
Keyboard
B.
Mouse
C.
Floppy drive
The correct answer is A.
The keyboard is typically associated with the
System.in
object. The mouse and floppy drive wouldn't work very well as standard input devices, and therefore would probably never be associated with the
System.in
object.
4.
Which one of the following methods is used with the
System.out
object to print information to standard output?
Please select the best answer.
A.
printf()
B.
println()
C.
printLine()
The correct answer is B.
The
println()
method is used with the System.out object to print information to standard output.
printf()
is the way to print information to standard output in C and is not supported in Java. There is no method named
printLine()
associated with the System.out object in the Java API.