The string literal are enclosed in . . . . . . . .

Quotation mark
Question mark
Exclamation mark
Dollar mark

The correct answer is: A. Quotation mark

A string literal is a sequence of characters enclosed in quotation marks. The quotation marks can be single quotes (‘) or double quotes (“). The string literal is interpreted as a single entity, and the characters between the quotation marks are not interpreted as special characters.

For example, the following code defines a string literal:

string str = "Hello, world!";

The string literal “Hello, world!” is stored in the variable str. The string literal can be used in any place where a string is expected. For example, the following code prints the string literal to the console:

System.out.println(str);

The output of the code is:

Hello, world!

The other options are incorrect because they are not used to enclose string literals.

  • Option B: Question mark is used to end a question.
  • Option C: Exclamation mark is used to end an exclamation.
  • Option D: Dollar mark is used to represent a currency value.