wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

T_(b)(C)_4.1 Introduction to Java Program

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the purpose of comments in a Java program?

a)

To execute code

b)

To provide information about the program

c)

To define classes

d)

To store data

2.

What must every Java program contain?

a)

A comment section

b)

A user-defined data type

c)

A main method

d)

An input statement

3.

What does the main() method represent in a Java program?

a)

A comment section

b)

A user-defined class

c)

An output statement

d)

The entry point of the program

4.

Which of the following is a valid output statement in Java?

a)

System.out.write();

b)

System.out.print();

c)

System.out.display();

d)

System.out.show();

5.

What is the purpose of the Scanner class in Java?

a)

To accept user input

b)

To display output

c)

To create new classes

d)

To define data types

6.

Which escape sequence represents a new line in Java?

a)

\b

b)

\t

c)

\r

d)

\n

7.

What type of data does the nextInt() method of the Scanner class read?

a)

Boolean

b)

String

c)

Double

d)

Integer

8.

What is the correct way to declare a class in Java?

a)

define ClassName {}

b)

Class ClassName {}

c)

class ClassName {}

d)

create ClassName {}

9.

Which of the following is NOT a valid data type in Java?

a)

boolean

b)

int

c)

float

d)

string

10.

What does the body of the main method enclose?

a)

Parentheses

b)

Square brackets

c)

Angle brackets

d)

Curly braces