Java OCA OCP Practice Question 843

Question

Which of these are valid expressions to create a string of value "hello world" ?

Select 4 options

  • A. " hello world".trim ()
  • B. ("hello" + " world")
  • C. (new String ("hello") + " world")
  • D. ("hello" + new String ("world"))
  • E. "hello".concat (" world")


Correct Options are  : A B C E

Note

All the expressions are legal.

String literals are String objects and can be used just like any other object.




PreviousNext

Related