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. |
|
| |||||||||||
Interview Questions and Answers for 'This' - 21 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 | |||||||||||
Frequently asked at Manhattan Associates ( Based on 2 feedback ) | |||||||||||
| |||||||||||
Ans. Its an anonymous method without any declaration. Lambda Expression are useful to write shorthand Code and hence saves the effort of writing lengthy Code. It promotes Developer productivity, Better Readable and Reliable code. | |||||||||||
Sample Code for lambda | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   java8   lambda expression   architecture Asked in 58 Companies expert   frequent | |||||||||||
Try 1 Question(s) Test | |||||||||||
| |||||||||||
Ans. "this" keyword is a reference to the current object and can be used for following - 1. Passing itself to another method. 2. Referring to the instance variable when local variable has the same name. 3. Calling another constructor in constructor chaining. | |||||||||||
Sample Code for this keyword | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   this   object reference   constructor chaining intermediate   rare | |||||||||||
Try 3 Question(s) Test | |||||||||||
Very Frequently asked. Have been asked in HCL Technologies very frequently ( based on 3 feedback ). Among first few questions in many interviews. | |||||||||||
| |||||||||||
Ans. Abstract classes can have both abstract methods ( method declarations ) as well as concrete methods ( inherited to the derived classes ) whereas Interfaces can only have abstract methods ( method declarations ). A class can extend single abstract class whereas it can implement multiple interfaces. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   classes   abstract class   interfaces   abstract class vs interface   abstract classes vs interfaces Asked in 82 Companies basic   frequent | |||||||||||
| |||||||||||
Ans. No, because both this and super should be the first statement. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   oops  this   super   constructor Asked in 1 Companies intermediate   rare | |||||||||||
Try 2 Question(s) Test | |||||||||||
Frequently asked in high end product companies. Frequently asked in Deloitte. | |||||||||||
| |||||||||||
Ans. https://medium.com/javarevisited/internal-working-of-hashmap-in-java-97aeac3c7beb#:~:text=HashMap%20internally%20uses%20HashTable%20implementation,the%20entries%20into%20the%20map. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  hashmap  collections  hashmap internal implementation Asked in 20 Companies expert   frequent | |||||||||||
| |||||||||||
Ans. 1.this is a reference to the current object in which this keyword is used whereas super is a reference used to access members specific to the parent Class. 2.this is primarily used for accessing member variables if local variables have same name, for constructor chaining and for passing itself to some method whereas super is primarily used to initialize base class members within derived class constructor. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   oops   class   objects   inheritence   constructor   this   super   this vs super Asked in 1 Companies | |||||||||||
Try 1 Question(s) Test | |||||||||||
| |||||||||||
Ans. Used to represent an instance of the class in which it appears. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   oops   java keywords   this   basic interview question basic   frequent | |||||||||||
| |||||||||||
Ans. Static methods can be called using instance references wherein this would have made sense but static method can also be called using Class name wherein this would mean nothing and hence forbidden. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   static methods   this keyword | |||||||||||
Try 2 Question(s) Test | |||||||||||
| |||||||||||
Ans. Authentication is the process of verifying the identity and credentials of the user to authenticate him into the system. whereas Authorization is the process by which access to a segment , method or resource is determined. Authorization is usually a step next to authentication. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  authentication  authorization  authentication vs authorization Asked in 9 Companies basic   frequent | |||||||||||
| |||||||||||
Ans. Selenium WebDriver is a tool for automating web application testing.It helps in replicating the manual tester behavior like keyboard entry, mouse events etc and then matching the output against the expected. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  selenium  webdriver Asked in 37 Companies | |||||||||||
| |||||||||||
Ans. No. Even though "this" would mean a reference to current object id the method gets called using object reference but "this" would mean an ambiguity if the same static method gets called using Class name. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   oops   static   this keyword   this   yes no   why questions intermediate | |||||||||||
| |||||||||||
Ans. Assert works only if assertions ( -ea ) are enabled which is not required for Verify.Assert throws an exception and hence doesn't continue with the test if assert evaluates to false whereas it's not so with Verify. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  assert   junit   mockito   verify   testing   unit testing Asked in 5 Companies | |||||||||||
Very frequently asked. Usually followed by questions related to private constructor and synchronized access. Frequently asked in JPMorgan and TCS (Based on 2 feedback) | |||||||||||
| |||||||||||
Ans. http://www.buggybread.com/2014/03/java-design-pattern-singleton-interview.html | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   design pattern   singleton   at&t   ebay  fidelity india  united healthcare india Asked in 46 Companies intermediate   frequent | |||||||||||
| |||||||||||
Ans. Within instance method of the parent class that has other multiple methods that have been overridden by the derived classes. In such case a simple method call from the common method will always be made to the method definition in the parent class. But If we use this.methodCall , this will be polymorphic and will be made to the respective derived object overriding method. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   this keyword   java keywords | |||||||||||
| |||||||||||
Ans. It is a continuous integration tool written in Java. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   jenkins Asked in 6 Companies Basic   frequent | |||||||||||
Ans. To call the static method | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  this   this keyword   java | |||||||||||
| |||||||||||
Ans. It makes no difference whether we add this to the variable or not. The only use of this is in the cases where there are multiple variables with the same name and we want to distinguish between the member variable and local variable. In case this is not added ,this is automatically added by the compiler in the byte code. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  this keyword  member elements  member variables | |||||||||||
| |||||||||||
Ans. Yes, that can be done using Power Mock. Mockito doesnt provide a way to mock static methods. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Mockito  junit  powermock Asked in 1 Companies | |||||||||||
| |||||||||||
Ans. Yes | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  enum  enum within enum | |||||||||||
| |||||||||||
This question was recently asked at 'Fifth Third Bank'.This question is still unanswered. Can you please provide an answer. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve   Asked in 1 Companies | |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||