@FunctionalInterface Represents an operation on a single operand that produces a result of the same type as its operand. This is a specialization of Function for the case where the operand and result are of the same type. This is a functional interface whose functional method is apply(Object). Parameters: the type of the operand and result of the operator
Question : You have been asked to create a ResourceBundle which uses a properties file to localize an application. Which of the below example specifies valid keys and values ? ?
System.out.println(labels.getString("label1")); Here is an example of what the content of the property file could look like: label1 = Label 1 is done! label2 = Label 2 is through!
In order to provide strings in different languages, create a property file for each language, and suffix them with underscore (_) and then the language code. For instance: MyBundle.properties MyBundle_da.properties MyBundle_de.properties MyBundle_fr.properties All of these files should be located in the same package (directory). The file without language suffix (e.g. MyBundle.properties) is the default property file. In case no property file is available for the language (Locale) passed to the ResourceBundle.getBundle() method, and the system has no default Locale set (e.g. a German computer will have a German Locale as default), this file is read and returned as a ResourceBundle.
Question : You have been given below code, select the correct statement which applies to it. package com.hadoopexam; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader;
class Welcome { public static void main(String[] args) throws IOException { FileInputStream findings = new FileInputStream("HadoopExam.txt"); DataInputStream dataStream = new DataInputStream(findings); BufferedReader br = new BufferedReader( new InputStreamReader(dataStream)); String line; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); } } 1. br.close() statement will close only the BufferedReader object, and findings and dataStream will remain unclosed. 2. The br.close() statement will close the BufferedReader object and the underlying stream objects referred by findings and dataStream.
Correct Answer : Get Lastest Questions and Answer : Explanation: The br.close() statement will close the BufferedReader object and the underlying stream objects referred to by findings and dataStream. The readLine() method invoked in the statement br.readLine() can throw an IOException; if this exception is thrown, br.close() will not be called, resulting in a resource leak. Note that Garbage Collector will only collect unreferenced memory resources; it is the programmer's responsibility to ensure that all other resources such as stream objects are released.