Java / Constructor
Java Default Constructor.
The constructor that takes no parameters is termed as default constructor.
package com.javatutorials.urlshort; public class Fruit { Fruit() { // No parameters mentioned at open and close parenthesis. This is // the default constructor. System.out.println(" Example of a default constructor."); } public static void main(String[] str) { Fruit fruit = new Fruit(); } }
More Related questions...