What code would you use to tell if "schwifty" is of type String?
a. "schwifty".getClass().getSimpleName() == "String"
"b. schwifty".getType().equals("String")
c. "schwifty".getType() == String
d. "schwifty" instanceof String

Respuesta :

Answer:

d. "schwifty" instanceof String

Explanation:

Given

List of options

Required

Determine which answers the question.

The syntax to check an object type in Java is:

[variable/value] instanceof [variable-type]

Comparing this syntax to the list of options;

Option d. "schwifty" instanceof String matches the syntax

Hence;

Option d answers the question