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.
Q1691. How would you design a stack which, in addition to push and pop, also has a function min which returns the minimum element? Push, pop and min should all operate in O(1) time
Q1692. Write a program to sort a stack in ascending order You should not make any assumptions about how the stack is implemented The following are the only functions that should be used to write this program: push | pop | peek | isEmpty
Ans. String has an argument constructor that take char array as argument and creates a string.
There is no constructor available with String that takes in a character and creates a String. We can use StringBuilder which has a char argument constructor.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  character  char  char array  String  char to String  char array to String
Ans. Generics are a facility of generic programming that were added to the Java programming language in 2004 within J2SE5.0. They allow "a type or method to operate on objects of various types while providing compile-time type safety.
Help us improve. Please let us know the company, where you were asked this question :
Ans. ORM is the mapping technique, which maps object with relational data model. As we know that in java we need objects we can not user data in relational(in table form). So ORM is set of guideline which allows us to map relational data model in object form.
Help us improve. Please let us know the company, where you were asked this question :
Ans. We can store the references in a collection by adding to those objects in the collection. We can create a class "ObjectRegistry" with a collection or multiple collections with a search algorithm to look for the already collected objects.
Help us improve. Please let us know the company, where you were asked this question :
Q1700. Lets say we have a set "set1" with objects of Class A, Class has a non static string called element1, Write a code ( using lambda expression ) to see if there is any object in the set with element1 = "Hello".
Ans. Because String being an immutable object creates a new object upon each concatenation cycle. If there is any such need , we should use String Builder whose objects are mutable.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Any function call is slower than the code in the same method as Java has to maintain stack of meta and function call information. So recursion is slower.
Help us improve. Please let us know the company, where you were asked this question :
Ans. streams are used for sequential processing of data and parallel streams are used for parallel processing of data (only if the underlying processor is multicore).
Help us improve. Please let us know the company, where you were asked this question :
Q1719. What are the advantage of Abstract classes over interfaces with respect to Java 7 ? and What changed in Java 8 to help facilitate that in Java 8 ?
Ans. Abstract Classes provide default implementations of methods that are inherited by the classes that extend them, which was not the case for Interfaces. This changed in Java 8, where default implementations are provided for methods.
Help us improve. Please let us know the company, where you were asked this question :