Tells whether this stream is ready to be read. An InputStreamReader is ready if its input buffer is not empty, or if bytes are available to be read from the underlying byte stream. int java.io.InputStreamReader.read() throws IOException Reads a single character. Returns: The character read, or -1 if the end of the stream has been reached long java.io.Reader.skip(long n) throws IOException
Skips characters. This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached. Parameters: n The number of characters to skip Returns: The number of characters actually skipped
Question : You have been given below code, what is the expected output?
package com.hadoopexam;
public class Welcome { private T t;
public T get() { return t; }
public void set(T t) { this.t = t; }
public static void main(String args[]) { Welcome siteName = new Welcome<>(); Welcome userId = new Welcome();// line n1 siteName.set("HadoopExam.com"); userId.set(101);// line n2 System.out.print(siteName.get() + ":" + userId.get()); } } 1. HadoopExam.com:101
4. A compilation error occurs. To rectify it, replace line n2with: userId.set (Integer(101));
Correct Answer : Get Lastest Questions and Answer : Explanation: With generics, you write code for one type (say T) that is applicable for all types, instead of writing separate classes for each type.
Question : You have been given below class and its member variables ,
package com.hadoopexam;
public class Welcome { String name;
void setName(String name) { this.name = name; }
String getName() { return name; } }
Which action encapsulates the Welcome class? 1. Make the Vehicle class public.
Correct Answer : Get Lastest Questions and Answer : Explanation: Publicly visible data members violate encapsulation since any code can modify the name value of a Welcome object directly. It is important to make data members private to enforce encapsulation.