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. Spring Security is a powerful and highly customizable authentication and access control framework. It is the de facto standard for securing Spring-based applications. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. static is the keyword that makes it accessible even without creating any object and using class name only. Making it non static would like creation of object upfront before calling the method. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. static keyword is used to specify that the respective programming construct ( method , variable ) belongs to the class and not to its instance and is supposed to be shared by all instances of the class. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. General contract of hashCode is: 1.Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, 2.If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. 3.It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Factory Design Patterns is the pattern that recommends creation of separate Factory Object for creation of other object. So its like saying - If you want to create an object of ClassA, Talk to FactoryObject ( which is an object of FactoryClass ). FactoryObject in itself encapsulates the inputs and logic required to make the decision regarding the creation and construction of object. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. [Open Ended Answer] | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. Inner join is the intersection of two tables on the condition defined by the where clause i.e will get records from both tables matched by a column. Outer join is the union of two tables i.e will get all records from both tables and will put null in the columns where related records are not present. Left Outer join is the left union of two tables i.e all records from the table on the left and values from the right table for related records else null for the columns from right table. Right Outer join is the right union of two tables i.e all records from the table on the right and values from the left table for related records else null for the columns from left table. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. An Exception in java is the occurrence during computation that is anomalous and is not expected. Exception handling is the mechanism which is used to handle such situations. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. If the process / app is abruptly killed or terminated. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. A media access control address is a unique identifier assigned to network interfaces for communications at the data link layer of a network segment. MAC addresses are used as a network address for most IEEE 802 network technologies, including Ethernet and Wi-Fi. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. https://en.wikipedia.org/wiki/Database_normalization | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. class A { void test() { System.out.println("test() method"); } } class B { void test() { System.out.println("test() method"); } } Suppose if Java allows multiple inheritance like this, class C extends A, B { } A and B test() methods are inheriting to C class. So which test() method C class will take? As A & B class test() methods are different , So here we would Facing Ambiguity. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Throwable | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. No | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Braces, i.e () and [] have the highest precedence | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Static , Final , Synchronized, private , public , protected, volatile, transient, super, this,import , abstract,native,default (effective java 8), new | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Object Oriented - Java is object oriented but isn't purely object oriented as we have primitives along with objects. Platform Independent - As JVM provides the translation to the Machine code as per the underlying Operating System. Interpreted as well as compiled - Java files are compiled as class files and then class files are interpreted by JVM. Runs on a Virtual Machine - Which is JVM that acts as an independent sub environment. Multi-threaded - As applications can run on single thread as well as multi thread. Modularity - Through usage of Classes , methods and Interfaces. Robust Usage in variety of Application types - Web , Gaming, BigData. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. 1. for loop in java is used with a counter as following for(int counter=0;counter < 50;counter++){ System.out.println(list.get(counter)); } for iterating and printing the contents of a collection whereas foreach loop can be specified directly without the use of counter for(String str:list){ System.out.println(list.get(counter)); } 2. for Each loop syntax is more clean if we have to iterate over the elements of a collection and we need not keep track of the record count 3. For is preferred when we need loops without the usage of collections or Array of objects and entirely primitives are being used 4. for loop is preferred if we need to keep track of record count and have to perform some action of the basis of that. For example - If we have to print something after every 5 records, With for each loop in such case, we will have to keep a separate counter. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. http://www.java4s.com/java-servlet-tutorials/difference-between-servletconfig-and-servletcontext-in-java/ | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
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. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Modularity - First sign of good code is whether it has been segregated into methods and classes appropriately. I dont mind it in excess because I believe that is forward looking strategy as applications tends to expand and eventually become hard to read. Self Explanatory - Variables and methods should be named in a way that the code should be self explanatory even without comments. Use of Constant variables to explain use of literal. Proper Code Reuse - If there is anything being reused , it should be moved to parent classes / methods. Proper composition calls - Composed hierarchy should not be access in just single line. One or two levels is ok but having multiple levels make it hard to read and debug. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
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. https://www.tutorialspoint.com/javaexamples/thread_procon.htm | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. No, Every entity in hibernate needs to have a key, either primary or composite. If we dont have a primary key on table, there are various ways this problem can be countered. 1. By using composite key on entity ( make sure that the appropriate unique constraint in defined on columns in Database ) 2. By mapping Id in entity to ROWID of table. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Heap memory. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Because of the life cycle requirement for different type of values in java. variables initialized and used in functions needs to be destructed with the execution of function and hence kept in stack. Same is applicable for the object references initialized within the method. If objects would have been created in stack, they wouldnt have been passed around across methods and hence they are created on heap. So anything that is required beyond the scope of a method or function is kept on heap which is usually garbage collected by Java. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
| ||||
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. Select Name from EMPLOYEE where ID in (Select ManagerEmployeeId from EMPLOYEE Group By ManagerEmployeeId order by count(Id) LIMIT 1) | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
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. 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 ). | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() ![]() | ||||