answersLogoWhite

0

You cannot create methods inside a constructor

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Why constructor rather than classes in java?

Constructor is not an alternative to class. In Java, you create classes; the classes contain methods - including the constructor, which can be viewed as a special method. If you want to have a constructor, you need a class that surrounds it, so it's not one or the other.


What is concession constructor?

Constructors are basically used to evoke methods of a class creating its object..and as far as i know there is no constructor called concession constructor..


Is constractor create object?

No, that would be a constructor. A constructor is involved in creating objects.


Why there is the need of the constructor if you can assign the value to variables by the help of the methods ..?

A constructor is what allocates memory for an object. If you didn't call a constructor, you would have no object in which to assign values.


What happens when no constructor function is declared in a class - in Java?

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( ) ").


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.


Use of constructor?

to create an instance of object


How do we invoke a constructor?

In Java, objects are constructed. Every time you make a new object, at least one constructor is invoked. Every class has a constructor, although if you don't create one explicitly, the compiler will build one for you. Ex: class Test { public Test() { } // this is Test's constructor public void Test() { } // this is a badly named, // but legal, method } If you see the example above, you would have realized that the constructor looks a lot like methods. Below are the main distinguishing factors between the constructor and normal methods: 1. The Constructor's name is exactly the same as the name of the class 2. They do not have a return type (Please remember this. A Constructor cannot have a return type as part of the code) 3. Constructors cannot be static, abstract or final


Can you create a constructor for an interface in java?

NO, we cannot create a contructor for an interface in java.


Why constructor use in java?

To create objects of classes


How constructor automatically invoked?

when we create the object of that class


When the constructor is called how many times will it be copied?

constructor is called every times when we create object of class using new keywordand constructor can not be copied (vinayak shendre)