Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available. These pools will typically improve the performance of programs that execute many short-lived asynchronous tasks. Calls to execute will reuse previously constructed threads if available. If no existing thread is available, a new thread will be created and added to the pool. Threads that have not been used for sixty seconds are terminated and removed from the cache. Thus, a pool that remains idle for long enough will not consume any resources. Note that pools with similar properties but different details (for example, timeout parameters) may be created using ThreadPoolExecutor constructors. Returns: the newly created thread pool
Question : You have been given below code
package com.hadoopexam;
public class Welcome { public static int checkValue(String s1, String s2) { return s1.length() - s2.length(); }
public static void main(String[] args) { String[] siteArray = new String[] { "Hadoop" , "Quick" , "Training" }; // line n1 for (String siteName : siteArray) { System.out.print(siteName + " "); } } }
Which code segment from below, will help us to print as "Quick Hadoop Training"
Sorts the specified array of objects according to the order induced by the specified comparator. All elements in the array must be mutually comparable by the specified comparator (that is, c.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the array). This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. Implementation note: This implementation is a stable, adaptive, iterative mergesort that requires far fewer than n lg(n) comparisons when the input array is partially sorted, while offering the performance of a traditional mergesort when the input array is randomly ordered. If the input array is nearly sorted, the implementation requires approximately n comparisons. Temporary storage requirements vary from a small constant for nearly sorted input arrays to n/2 object references for randomly ordered input arrays. The implementation takes equal advantage of ascending and descending order in its input array, and can take advantage of ascending and descending order in different parts of the the same input array. It is well-suited to merging two or more sorted arrays: simply concatenate the arrays and sort the resulting array. The implementation was adapted from Tim Peters's list sort for Python ( TimSort). It uses techniques from Peter McIlroy's "Optimistic Sorting and Information Theoretic Complexity", in Proceedings of the Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474, January 1993. Parameters: the class of the objects to be sorted a the array to be sorted c the comparator to determine the order of the array. A null value indicates that the elements' natural ordering should be used.
Question : You have been given below code, which of the following statement, replace at n can produce "Hadoop Data Science Spark"
public static void main(String[] args) { List courseName = Arrays.asList(new Welcome(" Hadoop"), new Welcome(" Data Science"), new Welcome(" Spark")); Stream stream = courseName.stream(); // line n1
Stream java.util.stream.Stream.map(Function super Welcome, ? extends String> mapper)
Returns a stream consisting of the results of applying the given function to the elements of this stream. This is an intermediate operation. Parameters: The element type of the new stream mapper a non-interfering, stateless function to apply to each element Returns: the new stream