Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers | ||||
| ||||
Ans. boolean - java.lang.Boolean byte - java.lang.Byte char - java.lang.Character double - java.lang.Double float - java.lang.Float int - java.lang.Integer long - java.lang.Long short - java.lang.Short void - java.lang.Void | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
| ||||
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; } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||