drevon315 drevon315
  • 03-10-2019
  • Computers and Technology
contestada

Where is the error in this code sequence?

String s1 = "Hello";

String s2 = "ello";

String s = s1-s2;

java programming

Respuesta :

SerenaBochenek SerenaBochenek
  • 05-10-2019

Answer:

There is an error in "String s=s1-s2 ";

Explanation:

In java programming, we can subtract subtract two strings variable with "-" operator.Java programming does not  support an overload of the '-' operator.In java, we can use only "+" operator to append two strings variable.There is no such method to subtract strings in java.Therefore in the given code String s=s1-s2 will give an "bad operand type" error because we can not subtract one string variable from the second string variable.

Answer Link

Otras preguntas

differentiate with respect to x 4x3-12x2+14x
What is a BUG in terms of computer programming? A) An update in an operating system B) A circuit on the motherboard C) An error in a program's code D) A program
Select ALL the correct answers. These cartoons both depict both William McKinley and the concept of prosperity during the campaign for the presidency in 1896. N
What is the slope of this line? A. −34 B. −3 C. 34 D. 4
What was the Installment plan?
please help me i’ll give brainlist :)
how do you do this 20 pts.
Learning to listen and resisting defensiveness are steps toward becoming:
What is the slope of the line
Which sentence uses correct subject-verb agreement? A. Coins under my sofa is sticky. B. The musicians in our town plays a concert in July. C. Questions on that