5 years ago in Java Strings

Consider the following code snippet
String river = new String('Columbia”);
System.out.println(river.length());
What is printed?

[A] 6
[B] 7
[C] 8
[D] river
Loading...
Next Question

Overall Stats

Attempted 510
Correct 216
Incorrect 91
Viewed 203

Answers

Guest
Guest
Hackers Defined - 2 years ago

their will be error

Bhaumik Patel - 3 years ago

if we bind string with double quotes than it returns 11 as answer

Bhaumik Patel - 3 years ago

i think it must invoke compiletime error because while defining string we have to declare it between " "(Double quotes)

Shamsa hafeez
Shamsa hafeez - 2 days ago

Shamsa hafeez from Lahore, Pakistan is saying river is correct answer

bruh
bruh - 1 month ago

bruh from Guwahati, India is saying 6 is correct answer

Related Questions

What will happen if you try to compile and run the following code ?
public class MyClass {

    public static void main(String arguments[]) { 

    }

    public void amethod(String[] arguments) { 

    }

}

  • [A] error Can't make static reference to void method.
  • [B] error method main not correct
  • [C] error array must include parameter
  • [D] amethod must be declared with String

What is the output of the code ?
public class AQuestion{

      private int i = j;

      private int j = 10;

      public static void main(String args[]){

            System.out.println((new AQuestion()).i);

      }

}

  • [A] Compiler error complaining about access restriction of private variables of AQuestion.
  • [B] Compiler error complaining about forward referencing.
  • [C] No error - The output is 0;
  • [D] No error - The output is 10;

What is the difference between a TextArea and a TextField?

  • [A] A TextArea can handle multiple lines of text
  • [B] A textarea can be used for output
  • [C] TextArea is not a class
  • [D] TextAreas are used for displaying graphics