More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
name, argument list, return type and belong to the same class
Which of the following can be overridden ?
final instance methods
final static methods
non final instance methods
non final static methods
Q212. Which of the following is not the advantage of Mocking frameworks ?
a. It helps testing the module independently b. It helps in faster unit testing c. It helps in testing code even when external dependencies like service calls are not working d. It helps in doing end to end Integration Testing
Ans. It helps in doing end to end Integration Testing
Help us improve. Please let us know the company, where you were asked this question :
Q214. Which of the following is dependency exclusion ?
a. A doesn't depend on C and then A marks C as excluded. b. A Depends on B and B depends on C and then A can mark B as excluded. c. A and B depends on C and then they can mark C as excluded. d. A depends upon B and B depends upon C then A marks C as excluded.
Q215. Which of the following is false about Constructors ?
a. Constructor can be overloaded b. A no argument constructor is provided by the compiler if we declare only constructors with arguments. c. Constructors shouldn't have any return types , not even void. d. If super is not explicitly called, still super() is intrinsically added by the compiler.
Q220. What will happen if we don't have termination statement in recursion ?
Ans. Function call allocates a stackframe in stack. Every stackframe will use some memory to store local variables, parameters and to remember return address. Without terminating condition stackframes will keep consuming memory from stack and eventually program will result in stackoverflow error.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It could be worthy to move a method to util class if the method needs to be shared, doesn't require polymorphic behavior and need not be overridden in special cases.
Don't belong to one group through is-a relationship ( You can share through parent class method )
Don't implement a specific interface ( java 8 default methods )
Doesn't involve complex computing as you will be loosing the benefit of object state with just static method.
Doesn't require polymorphic behavior as static methods don't participate in runtime polymorphism.
Help us improve. Please let us know the company, where you were asked this question :
Ans. GET is supposed to get information from the server. Client sends the minimal information so that Server can respond with the response body on basis of request. For example - You want to get complete employment record for employee id 123
POST is supposed to send the information for submission. Payload or a Body is usually sent so that it can be persisted on the server. For example - Sending the complete information of an employee ( id, name , dept etc ) to the server for persisting it.
Help us improve. Please let us know the company, where you were asked this question :
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 )
Help us improve. Please let us know the company, where you were asked this question :
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.
Help us improve. Please let us know the company, where you were asked this question :
Ans. 1. Method local variables - These are declared and defined within a method ( instance or static methods ) and their scope is limited to the method itself. They are destructed once the execution of method completes. They are stored in stack memory.
2. Instance variables - These are declared as non static variables as part of the class.They are initialized as part of object creation ( constructor ) and are destructed by java's garbage collection mechanism and hence stored in heap.
3. Static variables - These are declared with the static keyword and are part of the class. They are initialized at the time of class loading and are destructed by java's garbage collection mechanism and hence stored in heap.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Such a class still can have member elements which can be inherited and hence facilitate code reuse. Moreover Abstract class can have non final static elements whereas interfaces are only allowed to have static final elements.
Help us improve. Please let us know the company, where you were asked this question :
Ans. No. Because java internally treats var args as arrays and hence both method declarations will generate the same byte code and hence would result in ambiguity while determining call binding.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Single instance means there is only 1 instance that will bear all the traffic load whereas Load balanced server means that there will be a cluster of servers that will host the application and load will be balanced distributed among them. Auto Scaling means that the number of instances will be expanded / shrunken based on the rule. Rule could be the traffic count , response time etc.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It means import all the classes and interfaces within java.util package and make them available to use within the current class or interface. This is shorthand wild card annotation for importing all classes within a particular package. This won't import the classes within the sub packages of java.util.
Help us improve. Please let us know the company, where you were asked this question :
Batching requires less resources but may result in loosing whole batch in case of failure whereas concurrency even though is little more expensive in terms of resources but would result in minimal loss in case of failure.
In case messages are to be consumed in a particular order, batching them in that order and then consuming them makes better sense.
if incoming messages are not continuous , it makes more sense to do concurrency as we need not wait for all messages to form a batch and flush. Though time sensitivity can be added but that would add unnecessary complexity.
Help us improve. Please let us know the company, where you were asked this question :
Ans. final keyword have meaning only to referenced and not the value. It means that the specified reference cannot be dereferenced. It doesn't control the value assigned to the memory that's being referenced. This is the reason that final object references doesn't mean that the object is immutable but means that the reference cannot be changed to point to new object.
In case of primitive types too, when we assign a reference to another, values are passed and not the object reference, and hence a new placeholder is created in memory with the same value. That is why final to that context means that you cannot change the assigned memory and there is no way we can have that memory place have another value.
Help us improve. Please let us know the company, where you were asked this question :