answersLogoWhite

0


Best Answer

The default constructor is an empty (only call the super constructor) with no parameters constructor inserted by the java compiler when you don't define a constructor in your class. If you write something like this:

public class NoConstructorClass{

//no constructor goes here

}

Then you get something like this:

public class NoConstructorClass{

public NoConstructorClass(){ // Default constructor that you didn't write

super();

}

}

User Avatar

Wiki User

โˆ™ 2010-05-06 21:10:25
This answer is:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
User Avatar

Add your answer:

Earn +20 pts
Q: What is Default constructor?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you rewrite the default constructor?

You are free to override the default constructor whenever you like. In fact, if you want to keep the default constructor when you also need a parameterized constructor, you have to override the default constructor in order to use it. Once you've written the parameterized constructor, the default constructor goes away.


What is a default parameterized constructor?

There is no such thing as a default parameterized constructor. The default constructor is always the 'no-arg' constructor and does not take any parameters or arguments as input


Default constructor in java?

If you don't type a constructor into your class code, a default constructor will be automatically generated by the compiler. The default constructor is ALWAYS a no-arg constructor. (Obviously the compiler has no clue what all arguments you might want for your class. So it takes the safe way out with a no argument constructor) A no-arg constructor is not necessarily the default (i.e., compiler-supplied) constructor, although the default constructor is always a no-arg constructor. The default constructor is the one the compiler provides! While the default constructor is always a no-arg constructor, you're free to put in your own no-arg constructor.


What is the default constructor?

if we write a code in java then we don't mansion a default constructor in it then compiler by default provide a default constructor and the main impotent role of default constructor in our program is that it initialize the member of the class then it is reason compiler provide a default constructor in our java program code .


How do you get a default constructor?

Default constructor in Java initialises all instance variables with default values. class program { int a; // default constructor initialises a to 0 }


How is the default constructor equivalent to a constructor having default arguments?

Any constructor that can be invoked without explicitly passing any arguments is a default constructor. Note that there can be only one default constructor so there can only be one constructor where all arguments have default values or one constructor that has no arguments, but not both. A constructor where all arguments have default values is a useful means of combining two or more constructors into a single default constructor, thus reducing verbosity and code duplication.


What are default constructors?

Default constructors is a term having to do with computer programming. A default constructor refers to a constructor that is automatically generated when an explicit constructor is missing.


When a object is passed to a function as argument why it is not generating an error if the parameterized constructor is defined and not the default constructor?

default constructor is used only when the programmer does not use a constructor to initialize objects. Once the programmer defines a constructor then the default constructor is no longer used


What is another name of default constructor?

No-Arg Constructor


What is a default constructor?

A default constructor is generated for a class if we did not specify any constructor for it. A default constructor is a public constructor that takes no arguments. For example: public class Test { } The compiler will turn this into: public class Test { public Test() { ... } }


What is an empty constructor?

An empty constructor takes no arguments and calls the default constructor


What is the access specifier for default constructor?

There is no such thing as an access specifier in Java. There are access modifiers. The default for a default constructor is 'public'.


What is a sample of default constructor?

A default constructor is a constructor that takes no arguments.Here's a sample:class c{int a,b;c() //Constructor 1{a=2;b=1;}c(int x, int y) //Constructor 2{a=x;b=y;}};Here, Constructor 1 is called the default constructor, while Constructor 2 is a parameterized constructor.


Can you overload a constructor without initializing any default constructor?

no


How many types constructors are there in java?

Default Constructor Parameterised Constructor Non Parameterised Constructor


Does the constructor is overloaded or not in c plus plus?

That depends on how you define body of class. If you do not define constructors then compiler will provide default constructor and it is not overloaded. If you create your own constructor you automatically overload default constructor.


When does the compiler supply default constructor for class in java?

Any time you don't write any constructor for your class, the compiler supplies the default constructor. In other words, if you wrote a constructor the compiler won't.


What is the difference between default constructor and parameterized constructor?

A default constructor is one that has no parameters (C++ also calls constructors with all default parameters a default constructor), while a parameterized constructor is one that has at least one parameter without a default value. Default constructors can be provided by the compiler if no other constructors are defined for that class or any class the class inherits from, while parameterized constructors must always be defined by the developer.


What is the general syntax of a default constructor?

There is no such thing as 'the general syntax of a default constructor'. A default constructor is one that is generated by the compiler if you don't specify any constructors at all. Semantically speaking, it is public and takes no arguments, but this is not 'syntax'.


Are you required to write a constructor method for a class?

No. If you do not write a constructor for you classes, the default Object constructor can still be used.


When do you get a default constructor?

You get a default constructor when you do not provide a constructor that takes no arguments. Such a (compiler provided) default constructor will only set up the object (initialize vftables and vbtables) and call constructors for base classes, but it will take no further action, with the result that your object will not be in a properly initialized state.


What is parameter constructor?

A parameter constructor is a constructor within a class with some arguments in it. class abc { abc()---------------------------------Default Constructor { } abc(int d)---------------------------Parameter Constructor { } }


Why in java default constructor is created when you are not create any constructor?

To ensure that an object for the class can be created even though the programmer did not explicitly create one. However, if you create a constructor with arguments, the system will not create the default constructor for your class


What is a argument constructor?

A constructor that has arguments in it.Ex:class Car {Car() { }Car(String s) { }}The line in bold is the argument constructor and the other is the default (no-arg) constructor


Do you have to declare a constructor every time you create a class?

Yes, If you don't a default constructor will be created for you.