Core java - Interview Questions and Answers for 'Raytheon' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Interview Questions


 2795 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core java - Interview Questions and Answers for 'Raytheon' - 1 question(s) found - Order By Newest

 Q1. Write a class / program that takes few numbers from the input and then output the average ?Core Java2017-01-27 14:26:00

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     Raytheon


Related Questions

  What is a stream and what are the types of Streams and classes of the Streams?
 Explain System.out.println ?
  What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
  Which class is used to read streams of characters from a file?
  Which class is used to read streams of raw bytes from a file?
 How Spliterator in Java 8 different than iterator ?
 Which is better in terms of performance - Iterator or Spliterator ?
 Difference between System.out.printf and System.out.println ?
 What is the difference between the Reader/Writer java.io hierarchy and the Stream class hierarchy?
 Why is it important to close files and streams ?




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: