answersLogoWhite

0


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

13y ago
This answer is:
User Avatar

Add your answer:

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

Can you declare and define the constructor within class?

Yes, you can declare and define the constructor within a class. A constructor is a special member function of a class that is automatically called when an object of the class is created. It is used to initialize the object's data members. The constructor can be declared and defined within the class definition or can be defined outside the class definition using the scope resolution operator (::).


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 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 constructor in cplusplus?

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


Why you use constructor instead of function?

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 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.


When a class uses dynamic memory what member function should be provided by class?

the copy constructor


How do you invoke the constructor function in c plus plus?

There is no such thing as a constructor function in C++ (constructors have no return value, not even void, and cannot be called like regular functions). Constructors are invoked rather than called directly, either by declaring a static variable of the class type, or via the C++ new operator.


What happens if a constructor is defined in class?

Nothing happens. The compiler successfully compiles the class. When a class does not have a specific constructor, the compiler places a default no argument construtor in the class and allows you to compile and execute the class. public class Test { } and public class Test { public Test(){ } } are one and the same.


What happens if a constructor is not defined in class?

Nothing happens. The compiler successfully compiles the class. When a class does not have a specific constructor, the compiler places a default no argument construtor in the class and allows you to compile and execute the class. public class Test { } and public class Test { public Test(){ } } are one and the same.


Can you define a constructor as private?

I dont think we can have Protected Constructors but yes we can have Private constructors. We can declare the constructor as Private to ensure that no other class can instantiate it. We use this in the singleton design pattern


What is the function of this in java?

this in java is a keyword that refers to the current object of the class. It is also used in constructor overloading when you want to invoke one constructor from another within the same class.