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. We have followed this practice in one of the project. The only downside we felt was the need to merge the new snapshot version to master after the release.
The Benefit is that it's easy to just ignore the branch if complete rollback happens and hence master remains in sync with production.
Help us improve. Please let us know the company, where you were asked this question :
Q2407. In what terms Java is better language than c and c++ ?
Ans. Java manages pointers intrinsically and gives no control over pointer arithmetic to coders and hence saves the applications from many possible problems like dangling pointers and memory leaks.
Java is platform independent and hence any application can be run on any hardware with the suitable JVM without building it separately for different hardwares.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Assigning a value of one type to a variable of another type is known as Type Casting.
Example :
int x = 10;
byte y = (byte)x;
In Java, type casting is classified into two types, Widening Casting(Implicit) widening-type-conversion and Narrowing Casting (Explicitly done) narrowing-type-conversion.
Widening or Automatic type converion - Automatic Type casting take place when,the two types are compatible and the target type is larger than the source type
Example :
public class Test {
public static void main(String[] args) {
int i = 100;
long l = i; //no explicit type casting required
float f = l;//no explicit type casting required
System.out.println("Int value " i);
System.out.println("Long value " l);
System.out.println("Float value " f);
}
}
Narrowing or Explicit type conversion - When you are assigning a larger type value to a variable of smaller type, then you need to perform explicit type casting.
Example :
public class Test{
public static void main(String[] args) {
double d = 100.04;
long l = (long)d; //explicit type casting required
int i = (int)l;//explicit type casting required
System.out.println("Double value " d);
System.out.println("Long value " l);
System.out.println("Int value " i);
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. Singleton class will have only one instance through out your application. Once the instance has been created, you can use it to change the state of that object, whereas for immutable class you cannot change the value that means you cannot change the state of it once assigned.
If you want to change the state/ different values, you can very well create two instance for that immutable class which JVM will allow.
Help us improve. Please let us know the company, where you were asked this question :
Ans. yes, Java is a class-based and object-oriented programming language. It is a platform-independent language i.e. the compiled code can be run on any java supporting platform. It runs on the logic of “Write once, run anywhere”.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Both provide the thread safety but the actual difference come when talk about performance. CHM gives best performance when no of writer threads are less in number.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Java provides its own implementations of the thread pool pattern, through objects called executors. These can be used through executor interfaces or directly through thread pool implementations which does allow for finer-grained control. The java.util.concurrent package contains the following interfaces:
Executor : a simple interface for executing tasks.ExecutorService a more complex interface which contains additional methods for managing the tasks and the executor itself.
ScheduledExecutorService: extends ExecutorService with methods for scheduling the execution of a task.Alongside these interfaces, the package also provides the Executors helper class for obtaining executor instances, as well as implementations for these interfaces.
Generally, a Java thread pool is composed of:
The pool of worker threads, responsible for managing the threads.
A thread factory that is responsible for creating new threads.
A queue of tasks waiting to be executed.
Help us improve. Please let us know the company, where you were asked this question :