Multiple choice technology web technology

String x = new String("Life");System.out.println( x.length);

  1. 4

  2. 5

  3. Runtime Error

  4. Compiler Error

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

String's length is a method that must be called with parentheses: length(). The code attempts to access length as a field without parentheses, which fails at compile time. This is a common syntax error when confusing methods with fields.