Interview Questions, Answers and Tutorials

Category: CONSTRUCTORS & ENUM

11 Constructors & Enum

11.1 | Constructors   Constructor declarations are similar to method declarations. However, the constructors’ names must be the same as the class name and it cannot return a value. The main objective of a constructor is to set the initial state of an object. When the object is created by using the new operator. The following code shows how to declare constructors with and without input parameters.       11.2 | ENUM   Enum is a Java keyword used to represent a fixed number of well-known values. For example, the number of days in a week, the number of…