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. No, Main method is the entry point into an application. An application usually contain multiple classes to perform a function. Lets take an example of a House, House usually have only one external Door and you may have internal doors to move around within a house. Internal Doors are methods of classes whereas External Door is a special method called main method. | ||||
| ||||
| Ans. 1. Regulation / Enforcement / Policy / Contract , It's primary use 2. Use as a collection of utility methods(since java 8 through default methods) 3. Collecting constants together, As Interface are lighter, it makes sense to use them instead of classes if no getters and setters required. 4. Creation of Custom Annotations 5. Special services like marker interface | ||||
| ||||
| Ans. Slaves are computers that are set up to build projects for a master. | ||||
| ||||
| Ans. A build is considered stable if it was built successfully and no publisher reports it as unstable. | ||||
| ||||
| Ans. Upstream project is a project whose successful build is required for executing the existing project build whereas Downstream project is the one that is waiting for the upstream project to build as it has the upstream project as dependency. For example - X project has an upstream project y and downstream project Z. So It means X has dependency Y and is a dependency for Z. | ||||
| ||||
| Ans. Broken Build means as unsuccessful build whereas unstable build means build was created successfully but one of the Post Build report failed or could be a Test failure. | ||||
| ||||
| Ans. Yes, It's an instance initialization block. | ||||
| ||||
| Ans. Constructor has the same name as class name whereas instance initialization block just have a body without any name or visibility type. instance initialization blocks are useful if we want to have some code run regardless of which constructor is used or if we want to do some instance initialization for anonymous classes. | ||||
| Ans. Instance Initializer block is used to initialize the instance data member. It run each time when object of the class is created. | ||||
| ||||
| Ans. It is a class level variable that is shared among the objects of that class. | ||||
| Ans. print method prints the argument passed to the method whereas println prints the argument and then prints the new line character. println is generally used if we want each output in a new line. | ||||
| Ans. No, It requires creation of atleast one Class. Creating an object of that class is not compulsory as we can write all our logic within main method which is static. | ||||
| ||||
| Ans. Earlier any class implementing an interface was supposed to implement all methods declared in an interface. There was no place for optionally implementing all or subset of methods.Though we have abstract classes wherein we could have provided such a mechanism by declaring some methods as abstract while providing definition for some. But as Abstract classes have a body and are comparatively heavier than interfaces and interfaces associate closely to the concept of providing interfacing than abstract classes, Java might have though of providing optional implementation for default methods. This way same interface can be reused in variety of ways rather than making copies of an interface to suit different needs. | ||||
| ||||
| Ans. When a DML is executed, the changes only stays in session and still not pushed to DB Tables, Commit is used to push those changes to the Tables. In case we realize that we don't want to commit those changes and would like to ignore them, we can use rollback. For example - You may like that for a banking transaction you would like to update the account balance only if the debit or credit record was correctly inserted, so you may like to encapsulate both DML's - insert for transaction and update for balance in a single transaction and would only commit if both succeeds else rollback. | ||||
| ||||
| Ans. Audit Tables generally stores Raw information to be reviewed in case of problems or determining impact. If Database space is an issue , and the audit information is rarely retrieved, one design could be to use compressed file system. | ||||
| ||||
| Ans. Anti-pattern is simply the creation of a pattern in your coding that negatively affects your code i.e the Negatives surpasses the positives. | ||||
| Ans. Though Logically both code segments are same, but first one is more efficient as the 3 checks are mutually exclusive. In second code segment, all conditions will be evaluated no matter what and will never result in short circuit. In first segment , max 2 conditions will be checked if x >= 10. | ||||
| ||||
| Ans. There are many problems with the code 1. The method returns void and hence we cannot return any integer value. 2. We cannot return more than one value from a method. 3. The code after 1st Return statement is unreachable. | ||||
| Ans. This error can result either on an insert, update or delete when any change in data results in duplicate record or subset of it having unique constraint on record or its subset. For example - If we have a unique constraint on a combination of columns and then trying to insert duplicate column values. | ||||
| Ans. This error most likely will be thrown during an insert statement, while inserting a value within a foreign key column which doesnt exist within the Parent column. For example - Trying to add a dept number reference within a Employee Table when the Dept doesnt exist in the Dept Table. | ||||
| ||||
| Ans. HashTable has been deprecated. As an alternative, ConcurrentHashMap has been provided. It uses multiple buckets to store data and hence much better performance than HashTable. Moreover, there is already a raw type HashMap. The only difference between the HashTable and HashMap is that Hashtable is synchronized whereas HashMap is not. Most of the synchronized collections have been deprecated and their raw alternative have been presented as preferred.Synchronization has a cost. Using synchronized collection in places where there is no need of it leads to useless utilization of resources. As these collections are rarely used in a static context or shared among threads, Java might have thought it better to just provide the raw collection and let developers implement synchronization if he feels the need to do so. HashMap is now presented as the default and the preferred way of using Map with read optimized hashing, and ConcurrentHashMap has been provided for synchronized access which provides better performance than HashTable. Because of this, Java thought it right to deprecate the use of HashTable.' Synchronization has a cost. Using synchronized collection at a place where there is hardly any need of it would means useless utilization of resources. As these collections are rarely used in static context or shared among threads, Java might have thought it better to just provide the raw collection and let developer implement synchronization if he feels the need to do so. As HashMap has been presented as default and preferred way of using Map with read optimized hashing, and ConcurrentHashMap has been provided for synchronized access which provides better performance than HashTable, Java thought it right to deprecate the use of HashTable. | ||||
| ||||
| Ans. When a Table Join itself , it's a Self Join. For example - we like to know the pair of department names where first dept has lesser employees than the later. Select D1.name , D2.name from Dept D1, Dept D2 where D1.employee_count < D2.employee_count | ||||
| ||||
| Ans. In first case we are trying to initialize Inner class object using the instance of Outer Class whereas in second case we are trying to initialize the Inner class object directly using the Outer class name. In second case , Inner class is "static inner class" as we cannot access "non static inner class" using Classname alone. In first case, the inner class could be either "static inner class" or "non static inner class". | ||||
| ||||
| Ans. Multi Level Inheritance is multi level hierarchy of classes. Here is the example - http://www.buggybread.com/2015/09/java-se-class-diagram-classes-that_603.html Class RoleList extends ArrayList which in turn extends AbstractList which in turn extends AbstractCollection. | ||||
| Ans. Deprecating the interface / or declaration doesn't make much sense as the implementation is deprecated and not the interface. | ||||
| Ans. No. It just marks the method and hence signals the client to refrain from using it. | ||||
| Ans. Deprecated annotation is for documentation purpose only. It doesn't enforce anything but would mark the method name as crossed to signify that the client should refrain from using it. | ||||
| Ans. If the branch is to be created from Trunk and we are using Eclipse. Go to the Trunk Copy of the Project Right Click the project and then Click Branch/Tag In the Create Branch / Tag Dialog, Add the Destination Branch Url Check whether we want to make copy from the Head Revision or some specific revision Number | ||||
| Ans. If it's just smaller change, and single person is working, then this approach is fine. Otherwise there are risk on loosing it on your machine. Moreover , If there are multiple people working , it makes it hard to share code. It's better to create a separate branch and then merge it later to trunk. | ||||
| ||||
| Ans. We creates separate branches for each project if development work is going on parallel and they are to be released at different times. Once the first release is done, we merge the branch changes into trunk. If they all have to go at one time, we usually would merge everything in the trunk itself. | ||||