If a class is not required to initialize its data member or does not contain data member, there is no need to write empty constructor explicitly . On class object creation, default constructor implicitly called will be enough.10 Eki 2016
Read moreShould I always use a constructor?
If you don’t implement a constructor, the compiler will implictly create a default constructor if the class needs a constructor. So it depends on what you’re really asking. If you’re asking if you can write a class without explicitly creating a user defined constructor, yes you can do that.
Read moreWhat if we dont use constructor?
you wouldn’t be able to create objects/instances of classes , basically: you would only be able to use primitive datatypes. Even you don’t write any constructor, a default constructor exists there. So you can still create objects without passing any parameters.
Read moreShould all Java classes have a constructor?
Java doesn’t require a constructor when we create a class . However, it’s important to know what happens under the hood when no constructors are explicitly defined. The compiler automatically provides a public no-argument constructor for any class without constructors. This is called the default constructor.2 Eki 2017
Read moreDoes every class have a constructor?
Every class has a constructor whether it’s a normal class or a abstract class . Constructors are not methods and they don’t have any return type. Constructor name should match with class name . Constructor can use any access specifier, they can be declared as private also.
Read more