Languages-Java [3i Infotech Placement]: Sample Questions 87 - 89 of 141

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

Question 87

Edit

Describe in Detail

Essay▾

When will you use an inheritance and abstract class?

Explanation

Inheritance

Types of Inheritance in Java
  • Extending a class by another class is known as inheritance.
  • Class which is inherited is the parent class, base class, or super class.
  • Class which extends base class is the derived class or child class.

Abstract Class

Abstract Class Implements the Interface
  • Contains one or more than one abstract method.
  • Cannot create new instance of an abstract class.
  • Is used as base for subclasses.
  • Inheriting an abstract class requires implementations to all its abstract methods.

Question 88

Edit

Write in Short

Short Answer▾

What is the constructor?

Explanation

  • Special method that initializes an object.
  • Usually has the same name as the class, and sets the initial value of the members of an object.
  • Resembles an instance method in java but doesn՚t have a return type.
  • Execution sequence of the constructor involves call to parent class constructor followed by derived class.
  • It cannot be inherited.

Question 89

Edit

Write in Short

Short Answer▾

How can we do validation of the field in a perfect case?

Explanation

  • Validation can be called each time before throwing the object to the server for processing. If it returns true further processing can be done.
  • This is ideal solution, but it brings overhead of code, time and effort.

Developed by: