Pages

Saturday 7 March 2015

JAVA QUESTIONS

What is use of This keyword and Super Keyword?
THIS:
Here is given the 6 usage of java this keyword.
·        this keyword can be used to refer current class instance variable.
·        this() can be used to invoke current class constructor.
·        this keyword can be used to invoke current class method (implicitly)
·        this can be passed as an argument in the method call.
·        this can be passed as argument in the constructor call.
·        this keyword can also be used to return the current class instance.
SUPER
·        super is used to refer immediate parent class instance variable.
·        super() is used to invoke immediate parent class constructor.
·        super is used to invoke immediate parent class method.


What is Annotation in Servlet?
Annotation represents the metadata. If you use annotation, deployment descriptor (web.xml file) is not required. But you should have tomcat7 as it will not run in the previous versions of tomcat. @WebServlet annotation is used to map the servlet with the specified name.

No comments:

Post a Comment