Java String Program Practice Test-4

What will be the output of the following java code?

public class Test {

public static void main(String[] args) {

String str="HELLO";

System.out.println(new String(str).toLowerCase());

}

}

What will be the output of the following java code?

public class Test {

public static void main(String[] args) {

String s = "ab";

for (int i = 0; i < s.length(); i++) {

System.out.print(s.intern());

}

}

}

What will be the output of the following java code?

public class Test {

public static int compareTo(Object obj, String s) {

if (obj == s) {

return 1;

} else {

return 0;

}

}

public static void main(String[] args) {

Object obj = "Hello";

String str = "Well";

System.out.println(compareTo(obj, str));

}

}

What will be the output of the following java code?

public class Test {

public static void main(String[] args) {

Object obj = "Hello";

String str = "Well";

System.out.println(str.compareTo(obj.toString()));

}

}

What will be the output of the following java code?

public class Test {

public static void main(String[] args) {

Object obj = String.valueOf("50");

String str= obj;

System.out.println(str);

}

}