Тёмный
No video :(

c# interview questions:-Prove that only 1 instance of the object is created for static classes? 

.NET Interview Preparation videos
Подписаться 159 тыс.
Просмотров 188 тыс.
50% 1

For more such videos visit www.questpond.com
See our other Step by Step video series below :-
Learn C# Step by Step in 100 hours :- goo.gl/FNlqn3
Learn Angular tutorial for beginners tinyurl.com/yc...
Learn MVC Core step by step :- tinyurl.com/y9j...
Learn MVC 5 Step by Step in 16 hours:- goo.gl/dmdakg
Learn MSBI Step by Step in 32 hours:- goo.gl/TTpFZN
Learn Xamarin Mobile Programming Step by Step :- goo.gl/WDVFuy
Learn Design Pattern Step by Step in 8 hours:- goo.gl/eJdn0m
Learn Data structures & algorithm in 8 hours :-tinyurl.com/yb...
Learn SQL Server Step by Step in 16 hours:- tinyurl.com/ja4...
Learn Javascript in 2 hours :- tinyurl.com/zkl...
Learn SharePoint Step by Step in 8 hours:- goo.gl/XQKHeP
Learn TypeScript in 45 Minutes :- goo.gl/oRkawI
Learn webpack in 50 minutes:- goo.gl/ab7VJi
Learn Visual Studio code in 10 steps for beginners:- tinyurl.com/lw...
Learn Tableau step by step :- tinyurl.com/kh...
In this video we will try to prove that only 1 instance exists for a static class.
We are also distributing a 100 page Ebook ".NET Interview Questions". If you want this ebook please share this video in your facebook/twitter/linkedin account and email us on questpond@questpond.com with the shared link and we will email you the PDF.

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 34   
@dnfvideo
@dnfvideo 3 года назад
Do not miss our Interview Question video series 30 Important C# Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-BKynEBPqiIM.html 25 Important ASP.NET Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pXmMdmJUC0g.html 25 Angular Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE--jeoyDJDsSM.html 5 MSBI Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-5E815aXAwYQ.html
@balu5991
@balu5991 9 лет назад
The title is already wrong you can not create the instance of static class so whats the point here "Prove that only 1 instance of the object is created for static classes"
@kishorem5428
@kishorem5428 11 лет назад
Statement is correct but proof is not correct/may have to think of other alternative. As shown in the video constructor got called only once because you marked it as static. And we can mark any class constructor as static whether the class is static or not. In such case of non static class having static constructor we can create any number of instances but constructor gets fired only once. then can you say with this proof that only one instance got created??
@yugalmail
@yugalmail 10 лет назад
you cannot create instance of Static Class
@mwaqasaz
@mwaqasaz 4 года назад
you are wrong
@JaimeBurciaga
@JaimeBurciaga 4 года назад
Static Classes are obects, not System.object, but objects. To call a constructor is different than to instantiate.
@ahmedabuel-nour3096
@ahmedabuel-nour3096 10 лет назад
you con't create an object form a static class at all , in fact you will do nothing with it because everything is static , so what is the point to create an object ?! so C# does not provide that to create an object for Static classes
@ChuckMaureen
@ChuckMaureen 6 лет назад
1) The existence of a static class is not an "instance". 2) The "icount" variable should have been incremented within the static class constructor to definitively prove the static class is not instantiated and is not called more than once with each reference to it.
@mwaqasaz
@mwaqasaz 4 года назад
class Program { static void Main(string[] _1) { MyClass.SomeMethod(); MyClass.SomeMethod(); MyClass.SomeMethod(); MyClass.SomeMethod(); MyClass.SomeMethod(); MyClass.SomeMethod(); MyClass.WriteCounts(); Console.ReadKey(); } } public static class MyClass { private static int count = 0; static MyClass() { count++; } public static void SomeMethod() { } public static void WriteCounts() { Console.WriteLine(count); } } With this code count = 1; therefore constructor is called once
@rickycosta86
@rickycosta86 5 лет назад
How do you create an instance of the class without the new keyword? It's not possible create an instance of a static class. Static means exactly that... You do not need to create an instance to access to the class members.
@vladikov05
@vladikov05 10 лет назад
We can also set break point inside constructor, change several times static variable and see how many times static constructor will be called
@vladikov05
@vladikov05 11 лет назад
Thank you for the video. You can also auto increment read only variable in static constructor - so it will be more effective Like this: public static class ClassStatic { static public readonly int iii = 0; . . . static ClassStatic() { iii++; }
@chandanadas7860
@chandanadas7860 4 года назад
wrong caption: static class can not be instantiated.and static constructor instantiate only once.
@reidgwn7508
@reidgwn7508 8 лет назад
Static constructors or any method for that matter without an access modifier is private.
@Racle89
@Racle89 11 лет назад
according to me .... static constructor are called when assembly will load by ClassLoader and there is no need of instance to call constructor because that's all handled by CLR.....
@pillorani
@pillorani 11 лет назад
Static constructors are by default private.. If a static constructor is not private, it can be called by code other than the system. Depending on the operations performed in the constructor, this can cause unexpected behavior.
@himanshuupreti9457
@himanshuupreti9457 7 лет назад
icount should be Inside constructor, so that multiple call still makes its value to only 1... how icount = 2 justifies that there is single instance created for static class
@kobiewilliams1153
@kobiewilliams1153 9 лет назад
Correct me if I am wrong but a static class cannot be instantiated, i.e. no memory can be allocated dynamically. The program code can only be used to call it. What happens is when the application is first executed at run-time the CLR loads the static class and all of its members into a section of the heap called the loader heap and within a the loader heap a section called high frequency heap. It is has global scope and it also has a lifespan which terminates when the application domain ends which classifies it as being stateless.
@videhyadav7431
@videhyadav7431 Месяц назад
Hello are you there I need help on this
@adishjain3073
@adishjain3073 4 года назад
If class having static and Non-static constructor, then why static constructor called first c#.net????
@harmenbos
@harmenbos 4 года назад
Why are static classes and methods not used by default in programming?
@Ramkumar_8765
@Ramkumar_8765 6 лет назад
when to use static class
@susmitadebnath7434
@susmitadebnath7434 7 лет назад
I was asked in an interview that what a singleton class can do what static class can't and vice Versa and when to use what? can you please answer that in a video?
@jitusurve
@jitusurve 7 лет назад
Singleton class can have it's instance that can be passed as method parameter Singleton class can be inherited Both these point are not valid for static class
@johnnyserup5500
@johnnyserup5500 6 лет назад
Singleton allows access to a single created instance of a class (object). Singleton objects are stored on the heap and static objects are stored on the stack A static class allows only static methods - you can use the methods without instantiating the class (no object) you typically use a static class as fx. utility functions which you need to use at various places in your project
@EdwinCloud
@EdwinCloud 11 лет назад
which means it is singleton, right?
@TellaTrix
@TellaTrix 6 лет назад
Sir please stop the zoom over particular line. Because it is distracting complete focus from video content. Request you to your complete desktop window should focus.
@anikbutt22
@anikbutt22 12 лет назад
very informative.. thanks alot..
@adam7.633
@adam7.633 6 лет назад
Thanks Professor
@atd80
@atd80 12 лет назад
where is object ??? You can't create static class object .
@rupalikulkarni1343
@rupalikulkarni1343 11 лет назад
correction : constructor of static class are private
@johnnyserup5500
@johnnyserup5500 6 лет назад
you say you create instance of static class, but that is not what you are doing. You increment at the wrong place in order to prove your point - this video shows that you have not really understood how static classes are used - however I like these videos, so please redo this one :-)
@CoReeYe
@CoReeYe 5 лет назад
"she sharp"
@E2rdzik
@E2rdzik 11 лет назад
speak slower please
Далее
Interface in C#
38:55
Просмотров 163 тыс.
😱ЖИВОЙ Чехол на Айфон🤪
00:38
Просмотров 273 тыс.
Cristiano Ronaldo Surpassed Me! #shorts
00:17
Просмотров 11 млн
C# Delegates explained
8:47
Просмотров 515 тыс.
😱ЖИВОЙ Чехол на Айфон🤪
00:38
Просмотров 273 тыс.