Science, asked by aishugaikwad, 6 months ago

which of the following type of class allows only one object of it to be created​

Answers

Answered by rubykushwaha07
2

Answer:

Singleton class

Explanation: Singleton class allows the programmer to declare only one object of it, If one tries to declare more than one object the program results into error. 2.

Explanation:

Mark me branlist please..

Answered by krithikasmart11
0

Answer:

Singleton class

Explanation:

Singleton class allows only one object of it to be created.

Singleton class-

1) In object-oriented programming, a singleton class is a class that can have only one object (an instance of the class) at a time.

2) After the first time, if we try to instantiate the Singleton class, the new variable also points to the first instance created.

3)So whatever modifications we do to any variable inside the class through any instance, affects the variable of the single instance created and is visible if we access that variable through any variable of that class type defined.

singleton class:

1)Make a constructor private.

2)Write a static method that has the return type object of this singleton class. Here, the concept of Lazy initialization is used to write this static method.

FINAL ANSWER - singleton class

SPJ2

Similar questions