Search Interview Questions | 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. |
|
| ||||
Core java - Interview Questions and Answers for 'Efi' - 7 question(s) found - Order By Newest | ||||
Very frequently asked. Among first few questions in almost all interviews. Among Top 5 frequently asked questions. Frequently asked in Indian service companies (HCL,TCS,Infosys,Capgemini etc based on multiple feedback ) and Epam Systems | ||||
| ||||
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory. x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object. Sample code: String x = new String("str"); String y = new String("str"); System.out.println(x == y); // prints false System.out.println(x.equals(y)); // prints true | ||||
Sample Code for equals | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   string comparison   string   object class   ==   equals   object equality  operator   == vs equals   equals vs == Asked in 294 Companies basic   frequent | ||||
Try 6 Question(s) Test | ||||
| ||||
Ans. All exceptions must be a child of Throwable. If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class. You want to write a runtime exception, you need to extend the RuntimeException class. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   exceptions   exception handling   user defined exceptions   throwable   architecture   library development   technical architect   technical lead | ||||
| ||||
Ans. With Collection classes , we cannot use primitive types. Moreover for any class using generic types, we cannot use primitive types. They add more functionality by means of additional methods. As their reference can be null , they offer consistent check for uninitialized state. They facilitate caching and reuse by means of constant Pools. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  wrapper classes  benefits of wrapper classes over primitives | ||||
Frequently asked in high end product companies. | ||||
| ||||
Ans. https://www.geeksforgeeks.org/lru-cache-implementation/ | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  cache  LRU cache  coding  code Asked in 10 Companies intermediate | ||||
| ||||
Ans. Abstraction, Encapsulation, Polymorphism , Composition and Inheritance | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  core oops concepts Asked in 65 Companies basic   frequent | ||||
| ||||
Ans. Immutable objects are thread-safe so you will not have any synchronization issues.Immutable objects are good for Map keys and Set elements, since these typically do not change once created.Immutability makes it easier to write, use and reason about the code (class invariant is established once and then unchanged)Immutability makes it easier to parallelize your program as there are no conflicts among objects.The internal state of your program will be consistent even if you have exceptions.References to immutable objects can be cached as they are not going to change. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  immutable  immutability classes   benefits of immutable  immutability classes Asked in 1 Companies | ||||
| ||||
Ans. 1. JVM that makes it platform independent and facilitates portability. 2. Garbage Collector that protects from Memory Leaks. 3. Only usage of references and not pointer arithmetic and hence protects the application from memory issues like dangling pointers, memory leaks etc. 4. Support for OOPs that makes application development and maintenance easy. 5. Facilitates library development through use of interface / abstract classes. 6. Facilitates creation of scalable applications. 7. Huge repository of libraries and pool of people with java skill. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  benefits of java  advantages of java basic   frequent | ||||