Multiple choice

What is the output of the given Java program?

public class MyClass
{
public static void main(String[] args)
{
String s = " Java Duke ";
int len = s.trim().length();
System.out.print(len);
}
}

  1. 8

  2. 9

  3. 11

  4. Compile time error

  5. Run time error

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

This is the correct choice. The program will print 9 as output.