answersLogoWhite

0

No. Static elements belong to the class, and the constructor belongs to the object (which is an instance of a class).

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is the use of a Static Constructor?

Static Constructor - It is a special type of constructor, introduced with C#. It gets called before the creation of the first object of a class(probably at the time of loading an assembly). See example below. Example: public class SomeClass() { static SomeClass() { //Static members may be accessed from here //Code for Initialization } }


What happen when static data field is initialised in a non static constructor?

It got initialized as you instructed.


Difference between static and non static constructor?

A static constructor is used to do anything you need done before any static methods are called such as static variable initialization. In Java (as in C#) when a static constructor is called is non-deterministic but will always be called before a static method on the same class.


Why can't declare construtor as a static final abstract?

Because of the following reasons:static - If a constructor is static, an object instance cannot invoke it to initialize itself (Because static members are not linked to an object)abstract - because an abstract class cannot be instantiated and hence it will not have a constructor. If you make a concrete class's constructor abstract - it cannot be instantiated. eitherways it makes no sensefinal - a constructor cannot be final (thats the way java is designed)


What is non static constructor in c sharp?

The non static constructors in C# are the ones participate in object creation, while static constructors are for loading class definitions. The latter one does not create object instance of the class being loaded Below are the example of both: public class Dummy { // static constructor, no modifier to the method static Dummy() { Console.Write("loading class Dummy"); } // the default non static constructor, in conjunction with new operator public Dummy() { Console.Write("creating an instance of Dummy"); } }


Can a derived class call the static constructor of a base class in .Net?

No. not directly. The static constructor is called by .net framework, not by your code. I always treat static constructor is the class initializer (not the instance one). The initialization routine is only called when the class definition being loaded. When the derived class is loaded, since this class derived from the base, it makes to go up the chain (of the hierarchy) to call those static constuctors. So, when a derived class is loaded, the static constructors of the hierarchy is called up. (any one of them had been loaded, the calling sequence stops). You cannot call those static constructor directly, nor you can skip "not to execute" them.


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


1 Explain the concepts of constructor and destructor Do you have to declare a constructor every time you create a class?

You only need a constructor if the default constructor will not suffice. Often times, it is useful to have a constructor that takes common parameters so that you do not have to write additional code. For example, a Point class might have a constructor for Point(int x, int y), which would be a shortcut for assigning x and y independently. Other classes may not need any default values assigned, and for this, it is acceptable to just use the default constructor. Finally, some classes are virtual, static, or abstract, and so may not need a constructor because the constructor is unnecessary (static), or may be defined elsewhere (virtual, abstract).


What is use of constructor in java?

Constructor is used to do something (written in constructor) immediately after object creation.


Which situation constructor is used?

Constructor is necessary when you are about to use instance of a class.


What is a static block?

A static block is a code block defined with the 'static' keyword and is not inside others blocks. The static block is executed when the class is first loaded and the main purpose is perform all the initialization that may not be appropriate inside a constructor.


What is the format of java file?

Class Ram { static {} //static block to execute something before main method Ram() //constructor {} {} //init block public static void main(String ss[]) { } other methods }