Tuesday, November 27, 2012

JSP (EL Implicit Objects)

  Identifier               Description

 pageContext          PageContext instance
 pageScope             Map-associates name and values of page-scoped attributes
 requestScope         Map-associates name and values of request-scoped attributes
 sessionScope         Map-associates name and values of session-scoped attributes
 applicationScope    Map-associates name and values of application-scoped attributes  parameters
 param                   Map-stores the primary values of the request parameters by name
 paramValues          Map-stores all values of the request parameters as String arrays
 header                  Map-stores the primary values of the request headers by name
 headerValues         Map-stores all values of the request headers as String arrays
 cookie                   Map-stores the cookies accompanying the request by name
 initParam              Map-stores the context initialization params of the appln by name

Wednesday, November 7, 2012

Java Tidbits .......................... ( Riding over Methods )

Method Overriding is form of Polymorphism . Since which method to be called will be  resolved at runtime  by the  object assigned to reference.

Rules for overriding are :

  • A method if overridden in subclass should have same argument.
  • same or  extended return type(Covariant)
  • arguments can be declared as final additionally in subclass provided the datatype is same .
  • can throw checked exception if base class method too throws the checked exception .
  • the exception thrown can be  either same or subclass of  thrown exception in base method.
  • // Rule hold only for checked exception 
  • Access modifiers can make it less restrictive, but not more restrictive.
Field Hiding
A subclass cannot override fields of the superclass, but it can hide them by declaring  with same name .
if  want to access  base class's field then  user super to invoke  field .

While implementing interfaces all above rules are applicable for overriding interface declared methods too.
Exception and return of covariant types are applicable .

Can a private method be overridden by a subclass?
NO! Since the subclass,  cannot inherit a private method, it therefore cannot override the method—overriding depends on inheritance.