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. Optimizing Resource utilization. When you open a file using any programming language , that is actually a request to operating system to access the file. When such a request is made , resources are allocated by the OS. When you gracefully close those files, those resources are set free.
In Java if you don’t close the streams and files, Garbage collection identifies the open files which have lost the reference and hence will close them.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Substitutability means that the type of the variable does not have to exactly match with the type of the value assigned to that variable. For example - Object reference of Parent object can hold derived object.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Abstract methods are the methods that need to be overridden in the derived class ( either as implementing method or again abstract method ) so it's not only allowed but its required to override abstract method in the derived class.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Yes, but in that case the derived class itself should be abstract. We cannot have an object of a class without definition for the method which has been declared abstract in the parent.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Executor - Simple Interface that supports launching new tasks.
ExecutorService - Subinterface of Executor, which adds features that help manage the lifecycle, both of the individual tasks and of the Executor itself.
ScheduledExecutorService - Subinterface of ExecutorService, supports future and-or periodic execution of tasks.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It doesn't matter how you define that method in implementing class. there will be only one definition provided and that method can be accessed using reference of either of the interfaces.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Include directive includes the file at translation time (the phase of JSP life cycle where the JSP gets converted into the equivalent servlet) whereas the include action includes the file at runtime.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Java provides a default constructor ( no argument ) if no constructor is provided by the programmer. Java makes a check during pre compilation if there is any constructor provided by the programmer. If any constructor is provided, Java understands that programmer has provided all the mechanism for initialization and construction of the object and may not even intend to create objects by calling a no argument constructor. For example - One may like to have objects created with self defined state otherwise restrict its creation.
We make the constructor private if we want to make a class singleton as we would like to restrict creation of new objects using new operator and default constructor. Similar could be the situation wherein we would like to construct objects in a particular manner only.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Classes having only static methods in java is called util classes. As they don't have specific object state, they are basically intend to have shared code and state through static elements and methods. They save resources by sharing code.
Help us improve. Please let us know the company, where you were asked this question :