Java String Program Practice Test-3

What will be the output of the following java code?

public class Test {

public static void main(String[] args) {

String str="null";

System.out.println(str.length());

}

}

What will be the output of the following java code?

public class Test {

public static void main(String[] args) {

String str = null;

if (str != null && str.length() > 8) {

System.out.println("Java");

} else {

System.out.println("spring");

}

}

}

What will be the output of the following java code?

import java.util.Arrays;

public class Test {

public static void main(String[] args) {

String str = "spring";

char c[] = str.toCharArray();

Arrays.sort(c);

String s1 = new String(c);

System.out.println(s1);

}

}

What will be the output of the following java code?

public class Test {

public static void main(String[] args) {

char ch = 'm';

String str=Character.toString(ch);

System.out.println(str);

}

}

What will be the output of the following java code?

public class Test {

public static void main(String[] args) {

String str = "madam";

String rev = new StringBuilder(str).reverse().toString();

boolean status = str.equals(rev);

System.out.println(status);

}

}