Describe the use of "instanceof" keyword.- The "instanceof" operator is used to test if the object is an instance of the specified type (class or subclass or interface). - It is also known as a type comparison operator as it compares instance with type. - It may either return true or false. - If it is applied with any variable which has null value ten it returns false.
What is the purpose of "this" keyword?- "this" keyword is used to refer current instance of object.
Some of the uses of "this" keyword are:
1. It can be used to refer current class instance variable. 2. It can be used to invoke current class constructor. 3. It can be used to invoke current class method (implicitly) 4. They can be passed as an argument in the method call. 5. They are passed as argument in the constructor call. 6. They can also be used to return the current class instance.
|