Answer:
"True" is the correct answer to this question.
Explanation:
The program to the given question as follows:
Program:
public class data //defining class
{
public static void main (String [] aw)//defining the main method
{
String x="OH"; //defining string variable x and assign value
System.out.println("assign value: "+x); //print value
x = new String("OH"); //defining instance variable and assign value
System.out.println("assign value by creating instance: "+x); //print value
}
}
Output:
assign value: OH
assign value by creating instance: OH
Explanation of the program:
In the above java program, a class data is defined, inside the class the main method is declared, In this main method a string variable "x" is defined that holds a value "OH", then we the print function to print this variable value.
In the next line, An instance of variable x is created, which holds a value "OH" in its parameter. In this question, both are correct because both hold the same value.