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. int convert(int binaryInt) { int sumValue=0; int multiple = 1; while(binaryInt > 0) { binaryDigit = binaryInt; binaryInt = binaryInt /10; sumValue = sumValue (binaryDigit * multiple); multiple = multiple * 2; } return sumValue; } | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Protocol buffers are language-neutral, platform-neutral, mechanism for serializing structured data. It is developed by google. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Generally Rest services don't have any registry like we have WSDL is SOAP and hence don't have a way to know the end points without looking at either the url mapping in controller or client code. Some restful service publish WADL (Web Application Description Language) and hence clients can locate the service end points. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Conventionally we need a WAR file to be deployed to server. Though with Spring Boot we can even deploy using jar. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Annotations are used to specify meta information about the code. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Yes , as both code and its meta information reside in the same file, it promotes better readability and maintenability. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Goto statement results in unstructured jumps in control from one code location to another and hence makes the code very difficult to read , maintain and debug. Moreover Goto can always be replaced using other statements like break / continue and hence results in structured movement of programming control. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Convention over configuration is a way of software design used by frameworks that attempt to decrease the number of decisions that a developer is required to make without necessarily losing flexibility. The objective is to reduce the unnecessary configurations and follow conventions to accomplish that. For example - DB Entity and DB Table name conventionally should be same and hence shouldn't require configuring mapping between the two. "Spring Boot" and "Ruby on Rails" have adopted this design principle. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Yes, It may result in some loss of flexibility as the application has to follow all conventions. Moreover it can contradict with other design paradigms or principles used in the application or framework. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Hibernate mapping configurations are used for mapping hibernate entities and corresponding DB Tables. Conventionally Entities and Table can share the same name and hence framework can provide implicit mapping instead of explicit mapping through configurations. Though it may result in little loss of flexibility in extreme cases but will work with all applications following the convention. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. It is used for intercepting the request. It's primary use is to implement security policy. All or specific request types can be intercepted and hence forwarded to authentication / authorization module so as to facilitate authorized requests to application. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. JVM and JDK are getting smaller. New command line tool called jshell that will add native support and popularize a Java way to REPL (Read-Eval-Print-Loop) private methods in interfaces Introduction of the module system or project Jigsaw JavaDoc Search Light version of JSON API HTTP2 client | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. It introduces a layer of adaptations before it reaches the final and desired interface. Moreover sometimes all requests are forwarded to adapter class. Some of such requests doesn't even require any sort of adaptions as they are qualified to call the final interface directly and introducing overheads. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Voltage converters / Power Adapters | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. The projects aims to organize the Java source code into independent modules and hence facilitate building them independently.So now we will have multiple core java jars instead of single one. This way of organizing the code would offer following advantages 1. Will make applications lighter as only required modules will be built with the application. Moreover there are some legacy packages currently which anyone hardly use. 2. Reuse same class whole identifiers across different modules. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. It means that now individual modules will be built independently instead of complete jdk built in a single jar file. So we will have multiple jars instead of single jar. Moreover this organization would result in lighter applications as they can just built themselves with the required jars and hence ignoring the not required and legacy modules. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. It means that Java is compiled to byte code that is platform independent and hence can be run anywhere or any machine. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Enumeration can iterate only legacy collections like Vector , HashTable and Stack whereas Iterator can iterate both legacy and non legacy collections. Enumeration is less safer than Iterator Enumeration is fail safe whereas Iterator is fail fast Iterator allows for removal of element while traversal whereas Enumeration doesn't have remove method. Enumerations were introduced in Java 1 whereas Iterators were introduced with Java 2 Enumerations have methods like hasMoreElements and nextElement whereas Iterators have methods like hasNext, next and remove | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. This is used to achieve runtime polymorphism in java. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Yes. Both concepts are independent of each other. Overriding depends on the methods with same name and signature whereas Overloading on same name but with different signatures. All definitions of an overloaded method can be individually overridden in the derived class. For example - Class A has overloaded methods "public void myMethod(String str)" and "public void myMethod(int x)" We can have derived class ClassB extends ClassA and hence can override both methods myMethod(String str) and myMethod(int x) in ClassB | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. mutual exclusion i.e the resource is not shareable and hence a process should have exclusive access to it at a particular time Hold and Wait i.e the process doesn't release all existing resources held by it before requesting for another one. No preemption i.e noone can forcefully release a resource held by another process and the process should voluntarily release the resource held by it. Circular Wait - For ex, P1 is waiting on resource to be released by P2, P2 is waiting on resource to be released by P3 and P3 is waiting on the resource to be released by P1 | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Livelock is when two threads or processes get deadlocked because they try to perform the same action to come out of a potential deadlock. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. We can get an array out of ArrayList by using toArray() method of an array list. String a[] = arrayList.toArray(); | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Public constructor is simple and easy as it's the default way of object creation. So there are no additional coding overheads as compiler provides the default constructor if none is provided by coder. With static final methods, it facilitates loose coupling by segregating the responsibility of object creation to a separate method. Validation can be done on the constructor arguments before calling it. Moreover if any adaption on the arguments is required that can achieved easily with factory method.On the flip side, there is coding overhead and additional method call. | ||||
![]() ![]() | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. It will print "true" with integers as well as strings. The reason is "Integer constant pool" and "String pool" String pool maintains pool of string literals. When a string literal is used for the first time, a new string object is created and is added to the pool. Upon it's subsequent usage , the reference for the same object is returned. Similarly java uses integer constant pool. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. http://www.devinline.com/2015/10/Lock-Vs-synchronized-in-java.html | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Synchronized List locks the whole list to provide synchronization and thread safety during the read or write operation, while, CopyOnWriteArrayList doesn’t lock the whole list during these operations. The CopyOnWriteArrayList class works according to its name i.e. copy-on-write which performs different actions for reading and write operations. For every write operation (add, set, remove, etc), it makes a new copy of the elements in the list. and for the read operations (get, iterator, listIterator, etc), it works on a different copy. So there is no additional overhead during a read operation and its read operation is faster than Collections.SynchronizedList(). Thus, COWAL is better for reading operation than Synchronized List. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() ![]() | ||||