Java supports a special type of methods, called constructor that enables an object to initialize itself when it is created. Constructors have the same name as the class it-self. Constructors do not specify a return type, not even void. This is because they return the instance of the class itself. A constructor is automatically called when an object is created. Syntax: Constructor_name([arguments]) { // body } Constructors are generally of two types. 1. Non-Parameterized 2. Parameterized KEYWORDS IN JAVA We are going to learn few regularly used keywords. 1. new 2. this 3. static 4. super 5. final new: The new keyword dynamically allocates memory for an object. Syntax: claas_name object _name = new class_name(); EX. Box b1 = new Box(); Box b2 = new Box(); We have already seen so many programs in wh...
PhD || Artificial Intelligence, Machine Learning, Soft Computing, Quantum Machine Learning, Data Sciences.