Javatpoint Logo

Anybody can answer my question please? Why doGet(), doPost() Methods are "protected"?

By: er.jay*** On: Tue Jan 29 10:15:59 IST 2013     Question Reputation3 Answer Reputation1 Quiz Belt Series Points0  4User Image
Hi,

Why methods of HttpServlet class are protected?

Except service (public void service(ServletRequest req, ServletResponse res))

Thanks



Up0Down

 
Because doGet() is called by the service() method.and service method.And they both are in the same package.So the doGet method is protected.
Suppose we don't want to give access of doGet() outside package then we used the doGet as protected.

Suppose its declaration is with public then we can't make it as protected at the time of override.

Thanks
Image Created0Down

By: [email protected] On: Mon Aug 29 20:22:43 IST 2016 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No