cool hit counter
Cafe4Java
Cafe4Java
 

SCJP Mock Exam 4 - Q4
Exam Objective: 6.5 Use capabilities in the java.util package to write code to manipulate a list by sorting, performing a binary search, or converting the list to an array. Use capabilities in the java.util package to write code to manipulate an array by sorting, performing a binary search, or converting the array to a list. Use the java.util.Comparator and java.lang.Comparable interfaces to affect the sorting of lists and arrays. Furthermore, recognize the effect of the "natural ordering" of primitive wrapper classes and java.lang. String on sorting.
Q4)
What is the output of the following code?
import java.util.*;
public class Cafe4JavaArrayAndList {
	public static void main(String[] args) {
		String[] strArray = {"Java", "AJAX", "JSP"};
		List<String> list = Arrays.asList(strArray);
		for (String s:list) System.out.print (s + " ");
		System.out.println ();
		list.set(1, "Servlet");
		for (String s:strArray) System.out.print (s + " ");
	}
}
  • A) Runtime Error

  • B) Compilation Error

  • C)
    Java AJAX JSP
    Java AJAX JSP
    
  • D)
    Java AJAX JSP
    Java Servlet JSP
    
  • E) Undefined
Answer to Q4


    <<<< Back to Q3 <<<<         >>>> Go to Q5 >>>>

Submit your feedback on this mock exam


 
 
Custom Search
     
Cafe4Java