Search Interview Questions | Click here and help us by providing the answer. Click Correct / Improve and please let us know. |
|
|||
|
| ||||
| Interview Questions and Answers - Order By Newest | ||||
| ||||
| Ans. Yes, that can be done using Power Mock. Mockito doesnt provide a way to mock static methods. | ||||
| ||||
| Ans. In Java JVM memory settings is done by use the arguments -Xms -Xmx. Use M or G after the numbers for indicating Megs and Gigs of bytes respectively. -Xms indicates the minimum and -Xmx the maximum. | ||||
| ||||
| Ans. Load the file in chunks and then process. If we need to do analytic, we can process analytic information for those chunks and then reprocess the processed information from each chunk. For example - we need to average all marks in the file. We can divide the file and load into 5 chunks and calculate average for each chunk. Then we can collect averages for all 5 chunks and then calculate the final average. | ||||
| ||||
| Ans. A Web service is a service offered by one system to another, for communication over web through http. XML are JSON are usually used for sending across information from one system to another. | ||||
| ||||
| Ans. https encrypts the data using SSL whereas http sends it as plain text, So https is secure protocol whereas http is not. Moreover https connects on port 443, while HTTP is on port 80 | ||||
| ||||
| Ans. DELETE FROM TABLE WHERE ROW_NUM NOT IN ( SELECT MAX(ROW_ID) FROM TABLE GROUP BY DUPLICATE_FIELD ) | ||||
| ||||
| Ans. public static Stream permutations(String str) { if (str.isEmpty()) { return Stream.of(""); } return IntStream.range(0, str.length()).boxed() .flatMap(i -> permutations(str.substring(0, i) str.substring(i 1)).map(t -> str.charAt(i) t)); } | ||||
| ||||
| Ans. There is no direct way to make stateful REST service but when first time request send to server, generate the token on server and send back to client. When every time new request is send the token is send to identify the request is coming from same client. | ||||
| ||||
| Ans. <a href="http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html" rel="nofollow">http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html</a> | ||||
| ||||
| Ans. An Error indicates serious problems that a reasonable application should not try to catch whereas An Exception indicates conditions that a reasonable application might want to catch. | ||||
| ||||
| Ans. [Open Ended Answer] | ||||
| ||||
| Ans. 59 23 28-31 * * [ "$(date +%d -d tomorrow)" = "01" ] && job_name | ||||
| ||||
| Ans. du -a /var | sort -n -r | head -n 10 | ||||
| ||||
| Ans. PID - process identification number is an identification number that is automatically assigned to each process when it is created USER - User Name PR - PR is the process actual priority NI is the nice value, which is a user-space concept. VIRT -Virtual Image (kb). The total amount of virtual memory used by the task. RES - Resident size (kb). The non-swapped physical memory a task has used. SHR - Shared Mem size (kb). The amount of shared memory used by a task. S - Process Status. The status of the task which can be one of: D = uninterruptible sleep R = running S = sleeping T = traced or stopped Z = zombie %CPU - % CPU usage %MEM - % MEM Usage TIME - Total CPU time the task has used since it started. COMMAND - Command which was used to execute the process | ||||
| ||||
| Ans. It is special literal. It is neither keyword nor identifier. Any reference in java that doesnt point to any object , gets assigned null i.e is a reference to null | ||||
| ||||
| Ans. toString() is an overloaded method of String class that is used to convert many data types to String, Boolean being one of them. toString(Boolean bool) | ||||
| ||||
| Ans. Collections in java is a framework of classes that provides an abstracted data structure to store and manipulate the group of objects. Each class is unique in the way it stores , search , sort and modify the elements. | ||||
| ||||
| Ans. int[] arr = {1,-1,2,-3,3,-4,4,5,6,-5,-6,-7,-8,8,9,-9}; List positiveNumbers = new ArrayList<>(); List negativeNumbers = new ArrayList<>(); for(int i = 0; i < arr.length(); i ){ if(I < 0){ negativeNumbers.add(i); } else { positiveNumbers.add(i); } } System.out.println("Positive Numbers:" + positiveNumbers); System.out.println("Negative Numbers:" + negativeNumbers); | ||||
| ||||
| Ans. 500 is Internal Server Error 404 is resource not found 400 is Bad Request 403 is Forbidden 401 is Unauthorized 200 is OK | ||||
| ||||
| Ans. Spring Boot is Springs convention-over-configuration solution for creating stand-alone, production-grade Spring-based Applications. | ||||
| ||||
| Ans. Maven is a build automation tool used primarily for Java projects. | ||||
| ||||
| Ans. static methods and static elements are shared by all objects of a class and hence could create problem. Static methods are not synchronized by default and hence could create problem when accessed through multiple threads. Static elements are shareable by class and hence state of one object could be altered by another object. Some limitations with Unit testing as not all mocking framework facilitate mocking them. Power mock allows but Mockito doesn't | ||||
| ||||
| Ans. Better Control - If the value is being used at multiple locations , that can be controlled better from single place. Any change would only require making single change. Meaning , Aliasing and Better Readability - Sometimes its easy to read the value by its meaning or alias ( 0 as ZERO or 0 as NEUTRAL_VALUE ). | ||||
| ||||
| Ans. Everytime an object is serialized the java serialization mechanism automatically computes a hash value by passing the meta information for the class. This id is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization | ||||
| ||||
| Ans. Select Name from EMPLOYEE where ID in (Select ManagerEmployeeId from EMPLOYEE Group By ManagerEmployeeId order by count(Id) LIMIT 1) | ||||
| ||||
| Ans. public class SingleTon { private SingleTon() { if (singleTon != null) { throw new RuntimeException("cant not create the object"); } } public Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException("can not be create"); } static private volatile SingleTon singleTon; public static SingleTon getInstance() { SingleTon singleTon = this.sample; if (singleTon == null) { synchronized (this) { singleTon = this.singleTon; if (singleTon == null) { singleTon = this.singleton = new SingleTon(); } } } return singleTon; } } | ||||
| ||||
| Ans. https://www.tutorialspoint.com/javaexamples/thread_procon.htm | ||||
| ||||
| Ans. Abstract classes provide a mechanism of interfacing ( using abstract method ) as well as inheritance ( extending abstract class ). So they should be used in place of interfaces in case there is some code ( methods ) or object body ( member elements ) that can be reused with inheritance. | ||||
| ||||
| Ans. Purchase condition is the condition that must be fulfilled before a promotion is applied and Reward is the benefit that is passed to customer. For Example - If promotion is "Buy 2 Quantity of X, Get Y Free" , Purchase condition is inclusion of 2 qty of X in Cart. Reward in this case would be 1 qty of Y. | ||||
| ||||
| Ans. In first case the whole loop will terminate as soon as any exception happens in the method calculate ( assuming calculate method is not handling its exception and those are thrown back at the calling method ) In Second case exception will be caught for individual iteration and hence it wont break the loop and will continue for the next iteration. | ||||