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.
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.
Help us improve. Please let us know the company, where you were asked this question :
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.
Help us improve. Please let us know the company, where you were asked this question :
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.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Default methods results in multiple inheritance of behavior and not of state. In case we try to implement multiple interfaces with default method having same name and signature, and don't override it in implementation class, it will throw an error.
For example -
interface MyInterface {
public void default myMethod(){
}
}
interface MyInterface2 {
public void default myMethod(){
}
}
class MyClass implements MyInterface,MyInterface2 {
}
This code will compilation error "Duplicate Default Method"
if we specify the definition of myMethod() in myClass, compiler won't complain and there is no conflict and MyClass can use overridden definition. But if we don't override myMethod() in MyClass, Java would be in conflict as to what definition should be carried to MyClass and hence throws compilation error.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Copy Constructor is used for creating a duplicate of another object. Duplicate object will have the same state of the copied object but will have independent values in different memory locations. Copy Constructor can be useful to create duplicates of immutable objects as the Original cannot be tampered. Moreover It can be useful if base copies are required for individual requests in threading.
Help us improve. Please let us know the company, where you were asked this question :
Ans. PUT requests are only meant to place the object as it is on server. For example - You want a file to be uploaded and then placed in a particular folder or you want an Employee object to be persisted in the table.
POST requests are also meant to transfer information from client to server but that information once received at the server is evaluated , modified or refactored before persisting.
Help us improve. Please let us know the company, where you were asked this question :
Ans. No, even if there is no payload, you can't hit the POST request by typing it into browser address bar. You will need a client that can make a POST Request.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Yes, compiler won't complain but at runtime it will give an error saying "Error: Main method not found in class". Even though we can use this method as any other private method, it cannot be invocate by executing the class.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It is the ability to deploy changes on the fly without need to first build , deploy and then restart. All these functions happens on the fly as soon as the changes are made to the code.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  hot deployment  deployment   container   application server  production support
Q1187. Difference between Hot and Cold Deployment ?
Ans. Cold Deployment is a conventional deployment mechanism that follows the multi step process to deploy code changes to the running app i.e Build -> Deploy - Restart.
whereas
Hot Deployment is deployment changes on the fly without need to first build , deploy and then restart. All these functions happens on the fly as soon as the changes are made to the code.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  Hot deployment  cold deployment  application server  production support
Q1188. What is wrong with the following if statement ?
Ans. It make sense only if we intend to modify either of the object and would like to preserve original state in other. Otherwise we can reuse the original object by making it singleton.
Help us improve. Please let us know the company, where you were asked this question :
Q1191. Does an ArrayList allow elements of different types ? If not, Why the following code works
List list1 = new ArrayList<>();
list1.add(1);
list1.add("1");
Ans. With Java 7 or Later.
If you don't declare the list to be of specific type , it treats it as list of objects.
int 1 is auto boxed to Integer and "1" is String and hence both are objects.
Help us improve. Please let us know the company, where you were asked this question :
Ans. No, If both Parent and Derived are outer classes.
public class Vehicle {
private static String manufacturingDate = "2016";
}
public class Car extends Vehicle{
public static void main(String args[]){
System.out.println(manufacturingDate); // error - The field Vehicle.manufacturingDate is not visible
}
}
Yes, If derived is the inner class of Parent.
public class Vehicle {
private static String manufacturingDate = "2016";
static public class Car extends Vehicle{
public static void main(String args[]){
System.out.println(manufacturingDate); // no problem
}
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. Yes, a Class is supposed to define all abstract methods declared in the interface. With Java 8 , Interfaces can have default methods which need not be implemented by the implementing class.
Help us improve. Please let us know the company, where you were asked this question :
Ans. IdentityHashMap is a class that implements AbstractMap and provides a data structure with Elements having Key Value pair, just like HashMap. It is similar to HashMap except that it uses reference equality when comparing elements.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Buffer is cleared in 2 circumstances, i.e 1. naturally when the buffer is filled and 2. explicitly when the method flush is called ( for flushing the residual )
Ideally we just need to call flush once at the end of file writing so that the residual content should be dumped to file.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Implementing Comparable interface means that the elements of the class are comparable i.e the class provides the implementation of compareTo method that would help comparing the elements.
This is usually required if we are planning to sort elements of a collection, If compareTo method is not defined , the sorting class / method could never understand a way to compare its elements in order to sort them.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Multiple Inheritance refers to the concept of a class inheriting multiple classes. Example - Class C extends Class A ,Class B. This is not allowed in Java.
Multilevel Inheritance refers to the concept of Inheritance in a chain. Example - Class B extends Class A, Class C extends Class B. This is permitted in Java.
Help us improve. Please let us know the company, where you were asked this question :