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 Rating | ||||
![]() ![]() | ||||
| ||||
Ans. NumberFormatException is the exception that Java throws when we try to convert one data type to the Number data type but the value is not parsable to be a Number. For example , the following code will result in the NumberFormatException String string = "Buggy"; int strtoInt = Integer.parseInt(string); | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. When executing tests it is common that multiple tests need similar objects to be created before they can run. @before specifies a method that provide that initialization for the set of Unit Tests. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. https://en.wikipedia.org/wiki/Travelling_salesman_problem | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. I use trace for debugging purpose. Info for displaying some important info, thought its rare as we have enabled info logging in production. Warn in case something went wrong but we still resume the flow in spite of it or have take alternate flow as its expected sometimes. Error logging in case it was completely unexpected and mostly when it breaks the flow. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Because the way float values are stored its not precise. For example - 0.1 is actually stored as 0.1000000000000000055511151231257827021181583404541015625 | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. http://stackoverflow.com/a/6548203/2789764 | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Using Runtime object. Runtime runtime = Runtime.getRuntime(); runtime.totalMemory(); runtime.freeMemory(); | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. There is a Java system property "sun.arch.data.model" that can tell if JVM is 32 bit of 64 bit System.getProperty("sun.arch.data.model") can be used to get that property. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Coupling is the degree of interdependence between software modules, a measure of how closely connected two modules are or the strength of the relationships between modules. Cohesion refers to the degree to which the elements of a module belong together. Cohesion measures the strength of relationship between pieces of functionality within a given module. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. http://www.logicbig.com/tutorials/core-java-tutorial/java-nio/java-watch-service/ | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Yes, we can use ZipInputStream class for compressing the FileInputstream object. | ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. Type erasure applies to the use of generics. When generics are used, they're pre compiled into compile time checks and execution-time casts. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Yes, When either we don't want an object to be created ( class having all static elements and hence not required ) or object to be created using a static method or static block. One such example could be a situation when we would like app to load objects at start up and we would like to restrict new object creation by any request. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. At Application level we use either Double or BigDecimal , preferably BigDecimal. At Database level we use Number with decimal precision 3. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. A dirty read occurs when a transaction is allowed to read data from a row that has been modified by another running transaction but not yet committed. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. That depends if the interface for the resource in Project B gets changed. If only the internal implementation is changed, No change is required in Project A. Project A is not even required to be rebuilt. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. 404 means the resource is not found on the server.The resource might not be deployed correctly. 500 means internal server error which means that resource was located but then it resulted in some exception or error. 200 means Ok. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. This scope is not transitive. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Step 1 - Upgrade the required dependency , perform build and check build errors Step 2.1 - If the error is of missing transitive dependency ( which is rare and means that the previous version has a dependency which is missing in the later version ), I would look for the dependency in google and hence will include it as direct dependency in Pom file. Step 2.2. If the error is for Duplicate dependencies , and the choice is between transitive and direct dependency, I usually remove the direct dependency. Step 2.3 - If the error is for Duplicate dependencies , and both are transitive dependencies. I first make a choice ( usually later version ) and then ignore the previous version dependency. Step 2.4 - If the error is for Duplicate dependencies , and there are more than 2 duplicates, I usually ignore it by specifying within maven-enforcer-plugin config. Step 3 - Perform a Clean Build. Step 4 - Check Maven Dependency Tree to make sure that Duplicates have been removed or dependency is there in case of missing dependency. Step 5 - Perform tests and make sure that there are no runtime problems. Step 6 - If there are runtime problems ( which very likely occurs if you have different version dependencies , very likely by doing 2.4 , you will have to remove step 2.4 and alternately perform 2.2 or 2.3 ) | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. https://www.redhat.com/archives/rhl-list/2005-April/msg04167.html | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. ALTER TABLE <Table_Name> ADD CONSTRAINT <Constraint_Name> FOREIGN KEY (<Column_Name>) REFERENCES <Foreign_Table>(<Foreign_Column>); | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. Polymorphism means the condition of occurring in several different forms. Polymorphism in Java is achieved in two manners 1. Static polymorphism is the polymorphic resolution identified at compile time and is achieved through function overloading whereas 2. Dynamic polymorphism is the polymorphic resolution identified at runtime and is achieved through method overriding. | ||||
![]() ![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
| ||||
Ans. Synchronize is used to achieve mutual exclusion i.e at one time, the segment of the code, method that has been declared synchronized should be executed by single thread only and hence the lock needs to be retrieved before executing the segment and then released. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?keyword=mock&category=code | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. ACID stands for Atomicity, Consistency, Isolation, Durability is a set of properties of database transactions. Atomicity means all or nothing. i.e parts of a transaction shouldn't commit if any one of them fails. Either the whole transaction should succeed or it should be complete rollback. Consistency means that any transaction should lead database from one stabe state to another. Isolation means that the execution of transaction results in a system state that would be obtained if transactions were executed serially. Durability means that when a transaction is committed it forms the permanent state of database. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
| ||||
Ans. The prototype pattern is a creational design pattern. It is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. Prototype is used when we need duplicate copies of objects. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. A finally block of code always executes, whether or not an exception has occurred.The only time finally won't be called is if you call System.exit() or if the JVM crashes first. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. But Collections.emptyList() returns an Immutable list whereas new arraylist() creates a mutable list. Advantage of getting an empty list using Collections.emptyList is that it returns a singleton list which can be shared among many references and hence made immutable. This is good fit for situations where we would like to initialize a list to basic minimum empty to avoid null pointer exception. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. No, identifier in java cannot start with a numeral. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Yes, we can define an inner class within interface.Inside the interface, the inner class is implicitly public static. So the following is legit in Java public interface BuggyBreadInterface { void doSomething(); public class BuggyBreadClass implements BuggyBreadInterface{ void doSomething(){ System.out.println("Do something"); } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() ![]() | ||||