NEW
Font size
WorksheetsT_(b)(C)_4.1 Introduction to Java Program
Total questions: 10
Worksheet time: 5mins
What is the purpose of comments in a Java program?
To execute code
To provide information about the program
To define classes
To store data
What must every Java program contain?
A comment section
A user-defined data type
A main method
An input statement
What does the main() method represent in a Java program?
A comment section
A user-defined class
An output statement
The entry point of the program
Which of the following is a valid output statement in Java?
System.out.write();
System.out.print();
System.out.display();
System.out.show();
What is the purpose of the Scanner class in Java?
To accept user input
To display output
To create new classes
To define data types
Which escape sequence represents a new line in Java?
\b
\t
\r
\n
What type of data does the nextInt() method of the Scanner class read?
Boolean
String
Double
Integer
What is the correct way to declare a class in Java?
define ClassName {}
Class ClassName {}
class ClassName {}
create ClassName {}
Which of the following is NOT a valid data type in Java?
boolean
int
float
string
What does the body of the main method enclose?
Parentheses
Square brackets
Angle brackets
Curly braces
