102k views
0 votes
In Java, when a numeric variable is concatenated to a String using the ____, the entire expression becomes a String. a. string statement b. plus sign c. concatenate statement d. equal sign

User Adamsiton
by
4.9k points

1 Answer

5 votes

Answer:

b) Plus sign

Step-by-step explanation:

The plus sign or addition operator (+) accomplishes concatenation. This is a greatly used in the Java's output Statement to combine values coming from different data types into a formatted output

consider the code snippet below which uses concatenation to output information about an individual

public class Name {

public static void main(String[] args) {

int age =18;

String name = "John";

System.out.println("His name is "+name +" and his age is "+age);

}

}

The + operator has been used to concatenate the int value age and the String value stored in name to the output

User Shanmugam M
by
5.3k points