www.HadoopExam.com

HadoopExam Learning Resources

Following are the Oracle Java and Oracle SQL Products Provided by HadoopExam Learning Resources
Free Core Java 1Z0-808 Training Java 1Z0-808 Questions and Answers Java 1Z0-809 Questions and Answers Questions for Oracle 1Z0-060 : Upgrade to Oracle Database 12c Administrator Oracle Database 12c: SQL Fundamentals

Question 13: You have been given below code, what is the expected behavior?

Question 13: You have been given below code, what is the expected behavior?

package com.hadoopexam;

import java.util.function.IntFunction;

import java.util.function.IntUnaryOperator;

import java.util.stream.IntStream;

class Welcome {

public static void main(String[] args) {

IntStream stream = IntStream.of(1, 2, 3);

IntFunction<Integer> inFu= x -> y -> x*y;//line n1

IntStream newStream = stream.map(inFu.apply(10));// line n2

newStream.forEach(System.out::print);

}

}

1. This code will compile and run perfectly and produce 102030

2. This code will compile, but give run time error.

3. This code will compile and run with the 302010 as output.

4. This code will be executed successfully by changing n1 line with this "IntFunction<IntUnaryOperator> inFu = x -> y -> x*y;"

Correct Answer : 4 Exp : : java.util.function.IntFunction<IntUnaryOperator>

@FunctionalInterface

Represents a function that accepts an int-valued argument and produces a result. This is the int-consuming primitive specialization for Function. 

This is a functional interface whose functional method is apply(int).

Parameters:

<R> the type of the result of the function

IntUnaryOperator java.util.function.IntFunction.apply(int value)

Applies this function to the given argument.

Parameters:

value the function argument

Returns:

the function result

IntStream java.util.stream.IntStream.map(IntUnaryOperator 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:

mapper a non-interfering, stateless function to apply to each element

Returns:

the new stream

I have cleared my Java 1Z0-808 Certification exam with 92% using this simulator

I have cleared my Java 1Z0-809 Certification exam with 96% using this simulator

You have no rights to post comments

You are here: Home Oracle Java 1Z0-809 Question 13: You have been given below code, what is the expected behavior?