Java Programming and Technical Programming

StringBuilder is less efficient and slower than StringBuffer. State true or false.

Read Solution (Total 1)

Java Other Question

Consider the below statements.

Statement 1 : Matcher class interprets the pattern in a String

Statement 2 : Matcher class matches the regular expression against the text provided

Which of the following is true?

A. Statement 2 alone is correct.
B. Both Statement 1 and 2 are incorrect.
C. Statement 1 alone is correct.
D. Both Statement 1 and 2 are correct
What is the output of the following program?

import java.util.regex.*;

class Test
{
public static void main(String args[])
{
Pattern p = Pattern.compile(".ech");
Matcher m = p.matcher("tech");
boolean b = m.matches();
System.out.println(b);
}
}

A. true
B. false
C. Compilation Error
D. Runtime Error