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. 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. 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. Subject has state, it keeps a list of observers. On the other hand, an Observable is really just a function that sets up observation. While Subjects are Observables, Subjects also implement an Observer interface.
Help us improve. Please let us know the company, where you were asked this question :
Ans. 1. The problem with double (x*100)/100 doesn't return exact x but few fractions lesser than x and then if you are using floor rounding , it makes a big difference
2. Rounding only after getting a result vs rounding each outcome of 2 operand make difference
3. Usage of inappropriate Rounding mode and Rounding scale.
4. Results with double and BigDecimal
Help us improve. Please let us know the company, where you were asked this question :
Q312. 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.
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 :
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 :
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. 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. Filters are used to filter object in stream on certail criteria. And 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 :