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. Request Body in case of Get Request has no meaning and hence it's not parsed when the request is received. Alternatively Request Parameters are passed as either Path Params or Query Params. | ||||
| Ans. No. Static methods cannot be overridden and hence make no sense to be declared abstract. | ||||
| Ans. DTO's are a kind of POJO's that are intended to transfer information across different architecture layers. | ||||
| Ans. VO or Value objects are the objects that are supposed to hold some value. For Example , Integer, Float , Money etc. | ||||
| Ans. POJO is Plain Java Object that holds only Member Elements , getters are setters and minimal processing on that. The primary purpose of such object is to either transfer information or keeping state for a while. They are not intended to provide any processing or transformation. | ||||
| Ans. DAO is Data Access Object which is used within Persistence Layer to make Database Transaction. For example , the class holding the Database connection and CRUD methods. | ||||
| Ans. DTO is Data Transfer Object i.e Pojo which is supposed to move between different layers of software architecture for transferring information. Example could be the object passed from client in case of web service call or the object passed to Persister for Database Persistence. | ||||
| ||||
| Ans. It stores the string as a character array with 2 bytes for each character. | ||||
| ||||
| Ans. 1. Issue with Jar and ClassPath Conflicts 2. Killing JVM will terminate all applications | ||||
| Ans. All members of a family share a common last name and thats how outsiders recognize them, but to recognize individual team members , we need an overloaded name and hence we use First Name along with Last Name to uniquely identify. Some members of a family have a Nick Name as the real name is very long or hard to call. So the Nick name overrides the Original Name in certain circumstances. | ||||
| ||||
| Ans. Web Service promotes looser coupling but with comes with coding and performance overheads. Jars provide better performance and may be lesser coding but are problematic with update distribution. If the situation doesn't require frequent dependency updates and if it's only read operation of persistence, Having dependencies should be a better choice , otherwise web service. | ||||
| ||||
| Ans. CRUD stands for "Create, read, update and delete" are the basic functions of persistence. | ||||
| Ans. Yes, But the method should have some return type as otherwise it will be treated as a constructor. | ||||
| Ans. Because having a void return type with the Constructor name will make it as a method name. As methods with the Class names are perfectly legit in Java, It needs some way to recognize the constructor and having none return type helps identify that. | ||||
| Ans. No, New operator actually returns the reference of newly created object. Constructor's purpose is to initialize the default state of the object by setting the initial values of the elements and hence returns nothing. | ||||
| ||||
| Ans. No, Its an Operator. | ||||
| ||||
| Ans. JRE or Java Runtime Environment is the Java Virtual Machine on which class files are executed. It includes borwser plugins that facilitates execution of class files in browsers. JDK or Java Development Kit includes JRE , compiler and development tools. | ||||
| Ans. Its always advisable to initialize all the member elements in case we don't use the compiler's default constructor as leftover member elements will have garbage values and may reflect and unstable state for the object. | ||||
| Ans. Yes , If the values to be set are known at the time of initialization and doesn't involve polymorphic behavior.If it's using Dependency Injection , then Constructor injection must be available. If it suffice the above conditions, then definitely its advisable to have them set through constructor as they eagerly load the values into the memory and save it fro multiple values assignment ( one through default constructor and then through assignment ) | ||||
| Ans. Fail fast systems are intolerant systems that fails at the first instance of smelling any problem. The objective here is to break the system instead of continuing with the possibly flawed processing. Example could be breaking the processing upon an exception. | ||||
| ||||
| Ans. Fail Safe systems are tolerant systems that continue processing even if they sense any problem. the objective here is to continue with the processing even if there are some problems instead of completely shutting it down. Example could be to catch an exception and still letting it complete with partial results. | ||||
| ||||
| Ans. Fail-fast iterators detect illegal concurrent modification during iteration and fail quickly and cleanly rather than risking arbitrary, non deterministic behavior at an undetermined time in future. Example could be of an Iterator failing if it smells ConcurrentModificationException. | ||||
| ||||
| Ans. Deployment Descriptor which is usually web.xml is used to specify the classes, resources and configuration of the application and how the web server uses them to serve web requests.This file is usually added to WEB-INF folder and contains following * Servlet entries and url mapping * Plugins * Some info regarding authentication / filters * Landing Page * Event Handlers | ||||
| ||||
| Ans. Constructors are used for initializing the object state once it is initialized and memory has been reserved for it. Destructor is used to de-allocate memory allocated by objects. There are no destructors in Java. Alternatively, Java provides Automatic garbage collection i.e automatically releasing the un-referenced memory. | ||||
| Ans. All methods defined in a class that are not marked static are actually instance methods. | ||||
| ||||
| Ans. Car Engine is an example of encapsulation and abstraction. You ignite the car using an interface called starter and least bothered about how the tire actually moves (This is abstraction). The engine encapsulates the complete process to itself only and doesn't allow you to start the other components like the radiator etc ( this is excapsulation ) | ||||
| Ans. It makes no difference whether we add this to the variable or not. The only use of this is in the cases where there are multiple variables with the same name and we want to distinguish between the member variable and local variable. In case this is not added ,this is automatically added by the compiler in the byte code. | ||||
| ||||
| Ans. This depends on entirely upon the code type. For example 1.If its just logic, we can try it to short circuit or put the if / switch case with maximum probability in the beginning. 2. Can use faster data structures, for eg - random retrieval instead of sequence / iterator 3. Working with primitive types or even bytes instead of Objects, even though it may result in marginal improvement. 4. If its service call, then service call with bulk load can help 5. If DB Operation, then with use of Indices , Views or using ORM , cache etc. | ||||
| Ans. Composition for sure. Inheritance in case the reference of a parent class is used. If its interface, no Inheritance involved. | ||||
| ||||
| Ans. Declaration is intimation to the compiler about the nature of Data a reference is going to hold. For example - List myList; Instantiation is reservation of memory. For example myList = new ArrayList(); Initialization or construction is setting the default values for member elements. For example myList = new ArrayList(mySet); ** Example 2nd is both for instantiation as well as initialization. The only difference is that 2nd will initialized the member elements to their default values whereas 3rd will initialized it with the elements from set. | ||||