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

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Filter' - 6 question(s) found - Order By Newest

 Q1. What is an IO Filter ?Core Java2017-01-12 14:17:53

Ans. It's an object that reads from one stream and writes to another.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java io  io filter      intermediate


 Q2. What is a Servlet Filter ?Java EE2017-01-19 11:33:37

Ans. It's an object that can intercept http request and response and hence we can take appropriate action on those requests.

There are different types of filters based on Specifications like

Authentication
Logging
Encryption
Tokenizing

etc

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     servlets  servlet filters     Synechron  NexThoughts  Populus Group      basic        frequent


 Q3. What is the difference between filter and filter-mappings xml tag within deployment descriptor ?Java EE2017-01-19 11:36:25

Ans. filter tag speficies the filter name and respective class for handling filter action whereas filter mapping maps the filter to the url patterns ( specifying the url that needs to be intercepted )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     deployment descriptor  web.xml  filters  filter mapping


 Q4. What are the advantages of Spring interceptor over Servlet Filters ?Spring2017-01-30 10:30:32

Ans. Spring Interceptor are Spring beans and hence they can inject other beans and can be used with other Spring frameworks concepts like AOP.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interceptors  servlet filters  spring interceptors vs servlet filters


 Q5. Lets say we have a set "set1" with objects of Class A, Class has a non static string called element1, Write a code ( using lambda expression ) to see if there is any object in the set with element1 = "Hello". Core Java2017-08-06 11:51:10

Ans. set1.stream().filter(p->p.element1.equals("Hello")).findAny().isPreent();

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     lambda expressions  java 8  java8  java 8 filter  findAny()


 Q6. Write a Program that gets a set of numbers , filters out the non prime numbers , calculate the factorial of each prime number and then finds the average of all factorials using Lambda expressions2017-05-14 14:02:57

Ans. public class BuggyBread1 {
   
   public static void main(String args[]) {
      
      // Declare and Initialize the Collection
      Set<Integer> intSet = new HashSet<Integer>();

      // Add Elements
      intSet.add(1);
      intSet.add(2);
      intSet.add(3);
      intSet.add(4);
      intSet.add(5);

      double averageOfNonPrimeFactorials = intSet.stream().filter(p->checkIfPrime(p)).collect(Collectors.averagingInt(p->calculateFactorial(p)));
      
      System.out.println(averageOfNonPrimeFactorials );
   }
   
   static private boolean checkIfPrime(int num){
      for(int count=2;count < num;count++){
         if(num % count == 0){
            return false;
         }
      }
      return true;
   }
   
   static private int calculateFactorial(int num){
      int factorial = 1;
      for(int count=num;count > 0;count--){
         factorial = factorial * count;
      }
      return factorial;
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java 8  lambda expressions  lambda  filter  Collectors  factorial  prime number




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: