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.
Q152. While working on a web application, you are informed that there is no new data in Database for last few hours ? How would you go about debugging this problem ?
Ans. Will look into access logs to see if web application is getting any traffic. If not , then will inform the server support team.
Will look into intermediary infrastructure , queues , streams etc to see if there is any choke or throttle there.
If there is any throttle at any point, would make request for either debugging the cause or increasing the infrastructure. For ex - increasing shards in Kinesis.
Help us improve. Please let us know the company, where you were asked this question :
Ans. The load-on-startup element of web-app loads the servlet at the time of deployment or server start if value is positive. It is also known as pre initialization of servlet.You can pass positive and negative value for the servlet.
Help us improve. Please let us know the company, where you were asked this question :
Q156. suppose i have interface and i have declare lots of abstract method in interface But in sub class only two methods are use .than how to use oly two methods.
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. 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 :
Ans. It depends on how complex it is and if in future it would need any sort opf debugging. It's not easy to debug code if it's making heavy use of shortcuts like Lambda , Patterns etc.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Yes an application can have configuration stored at multiple places. Factors that could facilitate such a design could be
1. Type of config information - We may have a case to store confidential information differently than other regular config value
2. Environment - We may like to have a base config ( defined in application package ) and then a different override mechanism in different environments.
3. Centralization - Sometime some configs need to be shared across application and hence centralized.
4. Testing - Testing against config may not be possible in some enviornments in certain cases and hence additional config store might be kept for testing purpose only.
Help us improve. Please let us know the company, where you were asked this question :
Ans. We initialize two variables first and second to INT_MIN as,
first = second = INT_MIN
then Start traversing the array,
If the current element in array say arr[i] is greater
than first. Then update first and second as,
second = first
first = arr[i]
If the current element is in between first and second,
then update second to store the value of current variable as
second = arr[i]
then Return the value stored in second.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Caching is a mechanism that provides faster access but at the cost of additional space. Caching is good if we need faster access and if it takes extensive processing to come to a value which doesn't gets changed frequently.
Caching could be an overhead if we don't need fast access or if the processed value changes too frequently.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Broad question, but if the company need velocity, think about use a NO SQL instead of regular SQL databases.
Also prefers materialized views instead of joins to fetch data quickly.
Regarding the database design, there are very good design tools for professional database (to develop proper indexes and good database design) one of the best is QuickDBD
Help us improve. Please let us know the company, where you were asked this question :