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.
Ans. Filters are used to filter object in stream on certain criteria.
Collector is used to collect outcome of the stream. Collector is a terminal operation.
List numbers = List.of(1,2,3,4,5,6,7);
List evenNumbers = numbers.stream().filter(n -> n%2==0).collect(Collectors.toList());
The above code will filter out odd numbers and return the list of even number.
Help us improve. Please let us know the company, where you were asked this question :
Ans. public static void main(String[] args){
List<Integer> listOfIntegers = Arrays.asList(1,2,3,4,5,6,7,8,9,10,11);
List<Integer> perfectAndPalindromeIntegers = new ArrayList<Integer>();
Ans. The garbage collection is a facility wherein a program runs on the Java Virtual Machine which gets rid of objects, which are not being used by a Java application anymore. It is a form of automatic memory management and recollection.
Help us improve. Please let us know the company, where you were asked this question :
This question was recently asked at 'Bristlecone,Amazon Lab126,Amazon,Microsoft,Facebook,NCR,Google'.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 :
Q1013. Math.round method rounds the decimal to an integer by stripping off the decimal places. How can we use the same method to keep only 2 decimal places
For example -
Math.round(12.3456) will return 12. What should we do to get 12.34 without using any other class or method.
Ans. null is a literal similar to true and false in Java. These are not keywords because these are the values of something. As null is the value of a reference variable, true is the value of a boolean variable.
Help us improve. Please let us know the company, where you were asked this question :
Ans. A compiler directive is an instruction that tells the JVM how compilation should occur. A directive provides method-context precision in controlling the compilation process.
Help us improve. Please let us know the company, where you were asked this question :
Ans. final can be used for variables , methods and class. A final variable cannot be changed , a final method cannot be overridden , a final class cannot be inherited.
Finally is a block which is used after Try and catch, a finally block is always executed.
Help us improve. Please let us know the company, where you were asked this question :
Ans. The regular behavior of exception handling will occur. It will look for any immediate catch handler and if none is provided, it would be transmitted to the callers until a catch handler is found or it's out of main function.
Help us improve. Please let us know the company, where you were asked this question :