Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers for 'Stream' - 32 question(s) found - Order By Rating | ||||
| ||||
Ans. data under collection are actually stored in memory so that they can be retrieved when needed whereas data in streams are not stored and hence we need to construct it again when needed. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  collection classes  stream api  collection vs stream Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'SQUAD Infotech'.This question is still unanswered. Can you please provide an answer. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  stream  inout output  inour stream Asked in 1 Companies | ||||
| ||||
Ans. Which group of bytes represent which character is defined by character encoding. So when reading character by character from a stream of bytes using Reader, specifying character encoding becomes significant as the same group of bytes can represent different character in different character encoding(Eg UTF-8 and UTF-16 etc.) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  File io  File handling  Reader  Writer  Stream Asked in 1 Companies | ||||
| ||||
Ans. Map<DataType1,DataType2> where DataType1 is the data type of element1 ( returned by getelement1 method ) and DataType2 is the data type of element2 ( returned by getElement2 method ) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java 8  collections  java 8 streams | ||||
| ||||
Ans. We are averaging elements of a collection by element1 grouped by element1 * list is the reference of collection * element1 is the member element returned by getElement1 method of ClassA * element2 is the member element returned by getElement2 method of ClassA | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java 8  collections  java 8 streams  collectors | ||||
| ||||
Ans. This can be done using a Spliterator. LinkedList list = Arrays.asList("names","numbs","birds","animals"); Spliterator split1 = list.Spliterator(); Spliterator split2 = split1.Spliterator(); Now, the LinkedList is split into split1 and split2. use split2 first then split1 to check the output. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java 8  parallel stream  spliterator Asked in 1 Companies | ||||
| ||||
Ans. streams are used for sequential processing of data and parallel streams are used for parallel processing of data (only if the underlying processor is multicore). | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  stream vs parallel stream  stream  parallel stream Asked in 1 Companies | ||||
| ||||
Ans. A partition key is used to group data by shard within a stream. A partition key identifies which shard the message belong to. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Amazon AWS  AWS  Amazon Kinesis Stream  shard  shard in amazon kinesis   partition key in amazon kinesis   shard and partition key | ||||
| ||||
Ans. A shard is a uniquely identified group of data records in a stream or we can say that Shard is a partition in Kinesis stream. A shard supports a fixed bandwidth i.e fixed number of messages per second. The total capacity of the stream is the sum of the capacities of its shards. If the data rate changes, we can allocate / deallocate more shards to accommodate that. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Amazon AWS  AWS  Amazon Kinesis Stream  shard  shard in amazon kinesis | ||||
| ||||
Ans. OOPs or Object Oriented Programming is a Programming model which is organized around Objects instead of processes. Instead of a process calling series of processes, this model stresses on communication between objects. Objects that all self sustained, provide security by encapsulating it's members and providing abstracted interfaces over the functions it performs. OOP's facilitate the following features 1. Inheritance for Code Reuse 2. Abstraction for modularity, maintenance and agility 3. Encapsulation for security and protection 4. Polymorphism for flexibility and interfacing | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  oops  oops features Asked in 260 Companies basic   frequent | ||||
| ||||
Ans. A gobbler class take care of reading from a stream and optionally write out to another stream. Allows for non blocking reads when invoking a process through Runtime.exec(). Moreover the user can specify a callback that is called whenever anything is read from the stream. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  gobbler  stream | ||||
| ||||
Ans. public class Class{ public static void main(String[] args){ List<Integer> collector = new ArrayList(); Scanner scanner = new Scanner(System.in); int x = scanner.nextInt(); while(x != 0){ collector.add(x); x = scanner.nextInt(); } System.out.println(collector.stream().collect(Collectors.averagingInt(p->((Integer)p)))); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  coding  code  collector  streams  Collectors.average Asked in 1 Companies | ||||
Usually asked to entry level software developers. | ||||
| ||||
Ans. public static void main(String[] args) { int num1 = 1; int num2 = 2; num1 = num1^num2; num2 = num1^num2; num1 = num1^num2; System.out.print("num1 = " + num1 +", num2 = "+num2); } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  coding Asked in 37 Companies basic   frequent | ||||
| ||||
Ans. The Reader/Writer hierarchy is character oriented, whereas the Stream class hierarchy is byte oriented. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java io  streams intermediate | ||||
| ||||
Ans. Spring Security is a powerful and highly customizable authentication and access control framework. It is the de facto standard for securing Spring-based applications. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 3 Companies | ||||
| ||||
Ans. println prints an additional end of line whereas printf doesnt. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  System class  Streams  Input Output  println  printf | ||||
| ||||
Ans. System is a class within java.lang package that contains several useful class fields and methods. It cannot be instantiated and hence can use only statically.even in this case this has been used statically i.e with class name itself and without creating an instance. out is the static reference of Printstream declared as following in the System Class - public final static PrintStream out = null; println is the method of PrintStream class. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  System class  Streams  Input Output  println Asked in 1 Companies basic   frequent | ||||
| ||||
Ans. Spliterator has better performance potential than iterators but only if the potential is used. Spliterator can iterate streams in parallel as well as in sequence whereas iterator can only iterate in sequence. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  iterator  collections  streams  parallel streams  Spliterator | ||||
| ||||
Ans. Though there are many differences the way internally they both iterates the collections and streams respectively, but the main difference in performance that is achieved by spliterator as it can iterate Streams in Parallel whereas iterator only iterates collections sequentially. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java8  java 8  spliterator  java 8 streams  streams | ||||
| ||||
Ans. Yes, we can use ZipInputStream class for compressing the FileInputstream object. | ||||
Sample Code for ZipInputStream | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  file handling  FileInputstream  ZipInputStream  file handling | ||||
| ||||
Ans. It is an InputSream which is usually connected to the keyboard input of console program. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  System.in  Input Stream  Input Output | ||||
Frequently asked to fresh graduates. | ||||
| ||||
Ans. When two threads are waiting each other and cant precede the program is said to be deadlock. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   threads   multi threading   operating system   deadlock  concurrency Asked in 23 Companies basic   frequent | ||||
| ||||
Ans. BufferedWriter is temporary source for data storage.BufferedWriter is used to write character data to the file.Flush() is method available in B.W which ensures that all data items are written to file including last character.Close() is used to closes the character output stream. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   java io   input output   file handling   file io   output stream   bufferedwriter   flush   close | ||||
| ||||
Ans. Scanner class introduced in Java 1.5 for reading Data Stream from the imput device. Previously we used to write code to read a input using DataInputStream. After reading the stream , we can convert into respective data type using in.next() as String ,in.nextInt() as integer, in.nextDouble() as Double etc | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   java5   scanner   file io   file input   data input stream  file handling basic | ||||
| ||||
Ans. A Stream is an abstraction that either produces or consumes information. There are two types of Streams : Byte Streams: Provide a convenient means for handling input and output of bytes. Character Streams: Provide a convenient means for handling input & output of characters. Byte Streams classes: Are defined by using two abstract classes, namely InputStream and OutputStream. Character Streams classes: Are defined by using two abstract classes, namely Reader and Writer. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   file io   streams   byte stream   character stream  file handling Asked in 3 Companies | ||||
| ||||
Ans. The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented | ||||
Sample Code for InputStream Sample Code for OutputStream | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   file io   streams   reader class   writer class   inputstream   outputstream   stream  file handling | ||||
| ||||
Ans. OutputStreamWriter | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   io   file   fileio   filewriter   outputstreamwriter  file handling | ||||
| ||||
Ans. FileInputStream | ||||
Sample Code for FileInputStream | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   io   file   fileio   fileinputstream  file handling | ||||
| ||||
Ans. InputStream | ||||
Sample Code for InputStream | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   io   file   fileio   fileinputstream   inputstream  file handling | ||||
| ||||
Ans. FileNotFoundException | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   io   file   fileio   coding   code   scjp   ocjp   filenotfoundexception   fileoutputstream  file handling | ||||