(Java) Which of the following code segments correctly declare a Strings and gives it a value of "fortran".
A. String s;
s = "fortran";
B. String s = "fortran";
C. s = new String();
s= "fortran";
D. s= new String();
String s="fortran";
E. String s = ("fortran");
F. String s= new "fortran";

Select all that apply​

Respuesta :

In Java, variables must be declared before they are used. The correct declarations of string variable s are:

  • String s; s = "fortran";
  • String s = "fortran";
  • String s = ("fortran");

There are several ways to declare and initialize a string variable in Java. Some of them are:

  • String var_name; var_name = "string value"
  • String var_name = "string value";
  • String var_name = ("string value");
  • String var_name = new String(); var_name = "value";

By comparing the above variable declaration formats, to the list of given options; the correct declarations of string variable s are:

A. String s;  s = "fortran";

B. String s = "fortran";  

E. String s = ("fortran");

Read more about variable declarations at:

https://brainly.com/question/12987017

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE