3i Infotech Placement: Sample Questions 496 - 497 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 496

Edit

Statement

True-False▾

Final variables should be declared in the beginning?

Answer

TRUE

Explanation

  • True, final prevents modification of variable, but those have to be initialized at some point- constructor is the right place.
  • Value of a final variable can only be set once- constructor can guarantee this.
  • Constructor is called once for an object while other methods can be called any number of times.
  • A “blank final” instance variable of a class must be definitely assigned at the end of every constructor of the class in which it is declared.
  • A “blank final static” variable must be definitely assigned in a static initializer of the class.

Question 497

Edit

Describe in Detail

Essay▾

Why does java not support multiple inheritance?

Explanation

Java Supports Multiple Inheritance Using Interfaces
  • Common lisp and few other languages support multiple inheritance while java does not support.
  • Java does not allow multiple inheritances to avoid the ambiguity caused by it.
  • One of the examples of problem is the diamond problem that occurs in multiple inheritances.
  • Moreover, concrete classes have the option to implement multiple interface using single class.
  • Multiple interface inheritance allows an object to inherit many different method signatures with the caveat that the inheriting object must implement inherited methods.

Developed by: