Java Programming

BASIC CONCEPTS IN PROGRAMMING MULTIPLE CHOICE QUESTIONS

1

Which built-in Java class is used to read user input from the console?

A.

InputStream

B.

ConsoleReader

C.

Scanner

D.

UserPrompt

2

Which Java data type should be used to store a person's age, such as 25 or 42?

A.

double

B.

boolean

C.

int

D.

char

3

Which Java data type is best suited for storing a decimal number like 123.456 or 3.14?

A.

String

B.

double (or float)

C.

int

D.

boolean

4

Which data type should be used to store a person's name or a greeting like "Hello, World!" in Java?

A.

char

B.

boolean

C.

int

D.

String

5

Which Java data type is used to represent a single character enclosed in single quotes, such as 'A'?

A.

char

B.

String

C.

int

D.

double

6

Which data type can only hold two possible values: true or false?

A.

int

B.

boolean

C.

String

D.

char