Best Answer

When any constructor is deffined in your class, the java compiler create a default no argument constructor for you. This constructor only have an invocation to the super class constructor (" super( ) ").

User Avatar

Wiki User

โˆ™ 2010-05-26 21:59:55
This answer is:
User Avatar
Study guides


1 card


See all cards
22 Reviews

Add your answer:

Earn +20 pts
Q: What happens when no constructor function is declared in a class - in Java?
Write your answer...
Still have questions?
magnify glass
Related questions

Can the constructor be declared as private in a class?

Yes, a constructor can be declared private in a class. However, in order to instantiate the class, you must include a static member function, a friend function or a friend class. The latter is often the preferred method.

What is the definition of a base-class constructor?

A base class constructor is simply a constructor that is declared within a base class. There is nothing particularly special about them since all constructors are only of relevence and applicable to the classes in which they are declared.

What function initializes variable in a class?

The constructor.

What function initializes variables in a class?


What is conustrutor?

A constructor is a function in C which has the same name of the class. The constructor can be used to initialize some function.

What is friend constructor?

A friend constructor is a constructor that is declared a friend of another class and that grants that constructor private access to the class in which it is declared a friend. Example: class Y { friend char* X::foo (int); // friend function friend X::X (char); // constructors can be friends friend X::~X(); // destructors can be friends }; For more information, see '11.3 Friends' in the current ISO C++ Standard.

What will happen if you declared constructor in private section?

It becomes a singleton class.

What is constructor in cplusplus?

A constructor is a special member function which have same name as the class name.`

What is use of private constructor?

A Private constructor is simply a constructor that can only be used within the class it was declared in. By default java creates you a constructor which is public though. Hope that helps

What is the use of constructor function in a class?

For every class an empty constructor will be defined automatically by default unless you provide a constructor definition manually. Constructor in a class can be used to initialize variables or perfrom some basic functionallity whenever an object is created.

What is a class constructor in C plus plus?

A constructor is a function defined in a class with the name same as the class name and is used to automatically initialized the class data members. It is never preceded by a return type not even void. eg - class abc { int a, b; abc() //constructor { a=0; b=0; } }; main() { abc a; } The time we create object of the class in the main function the data members of the class are automatically initialised. Constructor can even take parameter. Those constructor are known as parameterised constructor.

What happens if a class defines constructor but not one with no argument?

Nothing Happens. Actually such a constructor is called a Default Constructor. Even if we do not write a constructor for a class, Java would automatically place a default constructor inside the class. Ex: Public class Test { public String getName(){ return "Hi"; } } Public class TestEx { public static void main(String[] args){ Test obj = new Test(); System.out.println(obj.getName()); } } Here we were able to instantiate an object of class Test even though we did not define a constructor for that class. This is because Java automatically places a default constructor for the class.

People also asked