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. Associativity determines whether an expression is evaluated left-right or right-left. When an expression has two operators with the same precedence, the expression is evaluated according to its associativity.
Help us improve. Please let us know the company, where you were asked this question :
Ans. = is the assignment operator that assigns the result of the expression on the right to the variable on the left, whereas
== is the operator to check object equality to see if the reference on left and right are pointing to the same object. For primitive types, its used to check if both variables holds the same value.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Array List works on Array and when we add an element in middle of the list, Array List need to update the index of all subsequent elements. I the capacity is full, it even may need to move the whole list to a new memory location . Linked List works on Double linked list algorithm and all it has to do is to adjust the address of the previous and next elements.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Though there are many differences the way internally they both iterates the collections and streams respectively, but the main difference in performance that is achieved by spliterator as it can iterate Streams in Parallel whereas iterator only iterates collections sequentially.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Spliterator has better performance potential than iterators but only if the potential is used. Spliterator can iterate streams in parallel as well as in sequence whereas iterator can only iterate in sequence.
Help us improve. Please let us know the company, where you were asked this question :
Ans. <a href="http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html" rel="nofollow">http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html</a>
Ans. No, Java doesn't have a sizeOf operator. In C / C++ , its required to determine how much memory allocation is required which is not the case with Java. Java handles memory allocation and deallocation intrinsically.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Its used to access the object properties using the object reference or class properties using the Class Name. Moreover its used to access the classes and Interfaces of a package.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Garbage collection mechanism frees up the memory that is no longer needed. In languages like C / C++ the deallocation needs to be done explicitly by the programmer and hence any leniency may result in memory leak. Garbage collection in java ensures that all unused memory is reclaimed and hence there are no memory leaks.Moreover it relieves the programmer from the hassle of carefully releasing all memory.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Enumeration can iterate only legacy collections like Vector , HashTable and Stack whereas Iterator can iterate both legacy and non legacy collections.
Enumeration is less safer than Iterator
Enumeration is fail safe whereas Iterator is fail fast
Iterator allows for removal of element while traversal whereas Enumeration doesn't have remove method.
Enumerations were introduced in Java 1 whereas Iterators were introduced with Java 2
Enumerations have methods like hasMoreElements and nextElement whereas Iterators have methods like hasNext, next and remove
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. There are four main OOP concepts in Java. These are:
Abstraction. Abstraction means using simple things to represent complexity. We all know how to turn the TV on, but we don?t need to know how it works in order to enjoy it. In Java, abstraction means simple things like objects, classes, and variables represent more complex underlying code and data. This is important because it lets avoid repeating the same work multiple times.
Encapsulation. This is the practice of keeping fields within a class private, then providing access to them via public methods. It?s a protective barrier that keeps the data and code safe within the class itself. This way, we can re-use objects like code components or variables without allowing open access to the data system-wide.
Inheritance. This is a special feature of Object Oriented Programming in Java. It lets programmers create new classes that share some of the attributes of existing classes. This lets us build on previous work without reinventing the wheel.
Polymorphism. This Java OOP concept lets programmers use the same word to mean different things in different contexts. One form of polymorphism in Java is method overloading. That?s when different meanings are implied by the code itself. The other form is method overriding. That?s when the different meanings are implied by the values of the supplied variables. See more on this below.
Help us improve. Please let us know the company, where you were asked this question :
Ans. No,we cannot.I t will give concurrentModificationExceptin error. It can be resolved by using ConcurrentClasses like ConcurrentHashMap,CopyOnWriteArrayList,BlockingQueue etc which are fail-safe and wont give exception.
Help us improve. Please let us know the company, where you were asked this question :
Ans. The garbage collection is a facility wherein a program runs on the Java Virtual Machine which gets rid of objects, which are not being used by a Java application anymore. It is a form of automatic memory management and recollection.
Help us improve. Please let us know the company, where you were asked this question :