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. ArrayLists aren't synchronized and hence doesn't allow synchronized access. As multiple threads can access an arraylist in parallel, it may result in an inconsistent state.
Help us improve. Please let us know the company, where you were asked this question :
Ans. We can copy the elements to a Set and then find the difference of count between ArrayList and Set. As Set don't allow duplicates , they will be removed in the set.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Encapsulation is a feature of OOP's that binds the data and it's associated methods together as a single unit and facilitate protection and data hiding by providing minimal interface to outside. For example - member variables are declared private and are accessed through public methods. Moreover we have private methods that can only be used internally and hence providing minimal interface to outside class through use of public methods.
Ans. A shard is a uniquely identified group of data records in a stream or we can say that Shard is a partition in Kinesis stream. A shard supports a fixed bandwidth i.e fixed number of messages per second. The total capacity of the stream is the sum of the capacities of its shards. If the data rate changes, we can allocate / deallocate more shards to accommodate that.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It's a configuration for auto scaling environment that specify the attributes / conditions for scaling instances up and down. For example - We may like environment to scale up when the number of requests / sec increases a particular threshold and scale down when it decreases below a threshold.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Manual scaling is the process of scaling instances up and down in a an enviornment manually by observing the scaling trigger whereas Auto scaling is the process wherein a Trigger condition specified as a scaling trigger will trigger scaling up and down of instances.
for example - If an organization has a policy of scaling up if requests / sec / instance exceeds 10000, Operations team will have to manually monitor the metric and they can request scaling up and down as the need arise. Manual scaling offers flexibility as team can scale on the basis of combination of factors and can take decision on flyby requires continuous monitoring.
The same trigger can be fed as triggering policy to the environment and can be taken care by the system. This requires availability of such triggering policy within the environment configuration but as it's automatically handled, requires no supervision.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  Scaling  manual scaling   auto scaling   manual vs auto scaling  production support
Ans. You can implement encapsulation in Java by keeping the fields (class variables) private and providing public getter and setter methods to each of them. Java Beans are examples of fully encapsulated classes. Encapsulation in Java: Restricts direct access to data members (fields) of a class.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Infinite loop is a programming condition wherein the control goes into an infinite loop because the loop termination condition can never be met. For example -
for(int x=1;x>0;x++){
}
in this loop, with each increment the condition x > 0 will remain true till infinity.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Ternary operator , also called conditional operator is used to decide which value to assign to a variable based on a Boolean value evaluation. It is used as
condition ? value1 : value2
For example
int y = (x > 0) ? x:0; // assign x if it's greater than 0, else assign 0
Help us improve. Please let us know the company, where you were asked this question :
Ans. Sometimes the calls move across layers of classes and functions and hence each layer needs to perform some function like cleaning if something goes wrong deep inside.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It makes application little heavy as we are importing classes that aren't required.
It creates class name conflicts as similar name classes might be available across different packages. In case of such conflicts, we will have to specify the package name with the class name at the time of it's usage.
Help us improve. Please let us know the company, where you were asked this question :