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. pop method pulls the top element from the stack and then move the top to the next element whereas peek only get the top element but doesn't move the top.
Help us improve. Please let us know the company, where you were asked this question :
Ans. In terms of compute options and configurations, Reserved Instances and On Demand instances are the same. The only difference between the two is that a Reserved Instance is one you rent (reserved) for a fixed duration, and in return you receive a discount on the base price of an On Demand instance.
Help us improve. Please let us know the company, where you were asked this question :
Ans. We can create API gateway and give the name of lambda function in order to be linked with lambda function, deploy the API and whenever request will be made from API it will directly be linked to lambda function to perform further process.
Help us improve. Please let us know the company, where you were asked this question :
Q520. Why do we need to specify import statement ? Don't you think Java could have been designed in such a way to automatically import everything that's in the class path ?
Ans. Java could design it in such a manner but would result in ambiguity if there are multiple files with the same name. The only way to get over it to show the message when you use any such class to provide explicit import with the package prefix. The other problem could be that Java might have to change the early import to Late import and check what's being used to decide what needs to be imported as otherwise you will see errors regarding the ambiguous imports with duplicate file name.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Encapsulation facilitate hiding and restricted access and hence more of a security feature. Encapsulation is definitely a great feature as when applications expand criss cross communication between objects / modules could lead to blunders.
Inheritance facilitates code reuse.
Polymorphism comprise of method overloaded ( which to me is negligible usage ) and method overriding. Method overriding is of great usage as it facilitates concept of interfaces and plugin development.
So it’s Security / Organization vs
Code Reuse / Support for other features like overriding vs
Contracts / Plugin Development facilitating the creation of frameworks / libraries.
Which is more important may vary from application to application , its scale , its use , its sensitivity etc.
Help us improve. Please let us know the company, where you were asked this question :
Ans. No. The whole idea of default method is to provide a default definition in case the implementing class intend to provide definition for only some of the methods. Making any of the interface method private would restrict it from being implemented by the implementing class. So default method is an option to provide implementation and not restricting a new definition.
Help us improve. Please let us know the company, where you were asked this question :
Ans. There are different types of relationship between classes
Inheritance - Also called is-a relationship, Child class object carries the body of the Parent class when initiated. Moreover there are certain privileges attach to method overriding to the classes related this way. This relationship exist for code reuse, method overriding and interfacing ( through abstract class ).
Composition - Also called has-a relationship. Class objects carries a reference to other class objects when instantiated. This relationship exist for work flow / work delegation.
Inner / Nested class - It’s a relationship that encapsulates the inner class or it’s object within the outer class. This relationship exist for encapsulation / security.
Help us improve. Please let us know the company, where you were asked this question :
Ans. 1. The problem with double (x*100)/100 doesn't return exact x but few fractions lesser than x and then if you are using floor rounding , it makes a big difference
2. Rounding only after getting a result vs rounding each outcome of 2 operand make difference
3. Usage of inappropriate Rounding mode and Rounding scale.
4. Results with double and BigDecimal
Help us improve. Please let us know the company, where you were asked this question :
Ans. Yes, to a certain extent. But the objective for Final class could be beyond just enforcing composition as certain classes might have been created without inheritance or composition in mind.
Help us improve. Please let us know the company, where you were asked this question :
Ans. 1. Enforcing composition over inheritance
2. Restricting overriding of certain methods
3. Final methods are faster than regular instance methods
4. Enforcing Immutability
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  final class   reasons for final class   restricting inheritance  object oriented programming (oops)  oops concepts expert
Ans. OAuth is an open-standard authorization protocol or framework that describes how unrelated servers and services can safely allow authenticated access to their assets without actually sharing the initial, related, single logon credential. Like using Google or Facebook to login to something.
Help us improve. Please let us know the company, where you were asked this question :
Ans. IP authentication is very restrictive, if IP changes for some reason then getting the new IP white listed on the server firewall could run your day pretty long. I would prefer encrypted password authentication cause it is not affected by IP changes and not limited to a white listed IP, I could use any different machine and get through authentication without any hassle.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Both Arrays and ArrayLists are used to store elements. Elements can be either primitives or objects in case of Arrays, but only objects can be stored in Arraylist. Array is a fixed length data structure while arraylist is variable length collection class. Once created, you cannot change the size of the arrays, but arraylists can dynamically resize itself when needed.Another notable difference between Arrays and Arrayslist is that arary is part of core java programming and array list is part of collection classes
Ans. Unreachable code is a code segment that can never be executed in any case. For example -
int x = 5;
return;
System.out.println(x);
In this code , 2nd line will return the control out of the method and hence 3rd line will never get executed and hence is unreachable code. This will be caught at compile time only.
Help us improve. Please let us know the company, where you were asked this question :