4. It accepts an argument and produces a result of any data type.
Correct Answer : Get Lastest Questions and Answer : Explanation: The Function interface defines a single abstract method named apply() that takes an argument of generic type T and returns an object of generic type R
A Function "operates" on something and returns something: it takes one argument (of generic type T) and returns an object (of generic type R). You can call apply() method on a Function object.
R java.util.function.Function.apply(T t)
Applies this function to the given argument. Parameters: t the function argument Returns: the function result
Question : Which statement is true about the DriverManager class?
1. It returns an instance of Connection.
2. it executes SQL statements against the database.
4. it is written by different vendors for their specific database
Correct Answer : Get Lastest Questions and Answer : Explanation: JDBC hides the heterogeneity of all the DBMSs and offers a single set of APIs to interact with all types of databases. The complexity of heterogeneous interactions is delegated to the JDBC driver manager and JDBC drivers. . The getConnection() method in the DriverManager class takes three arguments: a URL string, a username string, and a password string and returns the Connection with database. . The syntax of the URL (which needs to be specified to get the Connection object) is jdbc: :. . If the JDBC API is not able to locate the JDBC driver, it throws a SQLException. If jars for the drivers are available, they need to be included in the classpath to enable the JDBC API to locate the driver.
Question : You have been given below code, how will you replace n , so that it will print maximum value from given list?
Correct Answer : Get Lastest Questions and Answer : Explanation: In stream max() method you have to provide comparator and not comparable.
Optional java.util.stream.Stream.max(Comparator super Integer> comparator)
Returns the maximum element of this stream according to the provided Comparator. This is a special case of a reduction. This is a terminal operation. Parameters: comparator a non-interfering, stateless Comparator to compare elements of this stream Returns: an Optional describing the maximum element of this stream, or an empty Optional if the stream is empty Throws: NullPointerException - if the maximum element is null