Multiple choice

What will be the output of the given piece of code?

String s = �Welcome To Java�;

String s1 = �Java�;

s.match(s1);

  1. true

  2. false

    • 1
  3. Compile time error

  4. Run time error

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

This is the correct answer. The compiler will throw an error that method match() was not declared. Because String class do not contains any method named match(). The correct method is matches(). So the above statement should be s.matches(s1). So this is the correct answer.