3i Infotech Placement: Sample Questions 1191 - 1192 of 1245

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 1191

Edit

Describe in Detail

Essay▾

What are the advantages of inheritance?

Explanation

  • Reusability of code and accessibility of variables and methods of the superclass by subclasses.
  • The most frequent use of inheritance is for deriving classes using existing classes, which provides reusability.
  • Reusability -
    • Facility to use public methods of base class without rewriting the same.
  • Extensibility -
    • Extending the base class logic in derived class.
  • Data hiding -
    • Base class can keep some data private to prevent alteration by derived class
  • Overriding -
    • Inheritance can override methods of the base class so meaningful implementation can be designed in the derived class.

Question 1192

Appeared in Year: 2004

Question

MCQ▾

In the init (ServletConfig) method of Servlet life cycle, what method can be used to access the ServletConfig object?

Choices

Choice (4)

a.

Get Servlet Config ()

b.

Get Servlet Info ()

c.

Get Init Parameters ()

d.

None of the above

Answer

a.

Explanation

Public servletconfig getservletconfig () .

  • Returns a servletconfig object, with initialization and startup parameters for this servlet.
  • ServletConfig object was passed to the init method.
  • Interface implementations are responsible for storing the ServletConfig object so that this method can return it.
  • GenericServlet class is compliant.
  • Returns:
    • The ServletConfig object that initializes this servlet
    • See Also:
  • Init (javax. servlet. Servlet Config)

Developed by: