Correct Answer : Get Lastest Questions and Answer : Explanation: reusing a ResultSet is ok as well as long as you're properly closing it after you're done with it. You can reuse a single ResultSet and Statement as long as the operations are done in serial, not parallel. ie instantiate run query 1 with your Statement, get back value xyz from the ResultSet; close the statement, instantiate & run query 2 with your Statement using value xyz.
A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.
Question : You have been given below code, what is the expected behavior?
public final class Welcome { public static void main(String[] args) throws SQLException { List codes = Arrays.asList(1, 2); UnaryOperator unaryOperator = s -> s + 1; codes.replaceAll(unaryOperator); codes.forEach(value -> System.out.print(value)); } } 1. It will print 23
Correct Answer : Get Lastest Questions and Answer : Explanation: UnaryOperator is a functional interface and it extends Function interface, and you can use the apply() method declared in the Function interface; further, it inherits the default functions compose() and andThen() from the Function interface.
Question : You have been given below code, what is the expected output?
package com.hadoopexam;
public class Welcome { private String courseName; private String userName; private static int totalSubscriber;
Correct Answer : Get Lastest Questions and Answer : Explanation: A static variable is associated with its class rather than its object or instance; hence they are known as class variables. A static variable is initialized only once when execution of the program starts. A static variable shares its state with all instances of the class. You access a static variable using its class name (instead of an instance)
There are two types of member variables: class variables and instance variables. All variables that require an instance (object) of the class to access them are known as instance variables. All variables that are shared among all instances and are associated with a class rather than an object are referred to as class variables (Declared using the static keyword). . All static members do not require an instance to call/access them. You can directly call/access them using the class name. . A static member can call/access only a static member of the same class.
2. It will give "NullPointerException" when executed.
3. It will run perfectly and print as below. Welcome to HadoopExam Learning Resources Welcome to Training4Exam.com Welcome to QuickTechie Professional Network null
4. It will run perfectly and print as below. Welcome to HadoopExam Learning Resources Welcome to Training4Exam.com Welcome to QuickTechie Professional Network