Re: About abstract/sealed/virtual/override/new keywords...
Hi...It seems that there are a lot of things happening here...Our forums-mate cjard has got quite handsome 'blogging' skills and I do really appreciate them. Also, it seems that cjard has a deep interest in blogging. May be I am a little too young in the field of IT development and a little too immature to understand the versatility of a power-poster like the one and only "cjard". But, I would like "cjard" to be a little "verbose"(and not very discrete)
Quote:
bhushan1980 == (George2 with humanity upgrade 1.0 installed)?
Regarding the above quote:
I like the way it is build/represented...The presentation layer seems ok. But regarding the business logic, I have following Qs:
<1> What is the use of the Quote class provided above? Can I create an instance of it and understand how it would be of any help to me?
<2> Is there anything encapsulated/abstracted that I need to know? (Because if it was intended for me to know, and if that was abstracted, that is a wrong according to the OOPs paradigm. And further more complete encapsulation does not help either.) So, I urge you to explain the meaning of the Quote.
<3> If it is supposed to be shipped as a DLL, please provide relevant documentation.
<4> Atleast send me some really good string parsers that give the hidden meaning of the idioms/phrases that are way out of league of any famed literary person.
=====================================================
JOKES AND QUOTES apart...
Quote:
In an enterprise development, which one comes first - an abstract class or an interface?
This made sense to the interviewer! May be he just wanted to test the person whom he was interviewing. Although, I had a faint idea about the either being preceding the other one, I had to ask some of the other people and I am happy to say that I was right on this one.
Quote:
What is happens when the keyword abstract is used to declare and implement a method?
I admit that this was the non-sense question not because of the fact that the Q was non-sense, but the effort I put in answering what I knew about it in my second post, just held myself back a little bit. So sorry about it.
Quote:
Can we have virtual/override/new keywords attached to a contructor in C#?
Again its the interviewer's stupidity. Cannot do anything about it. Yet it is always good to know. I would have normally said that the code would not compile.
Quote:
What is the analogous of C# static keyword in VB.NET?
Is there a C# equivalent for keywords My, AddressOf, With in C#?
Answers to both the questions are really good. And I really appreciate them. I had not got them so far....
Thankyou and Regards,
Bhushan.
Re: About abstract/sealed/virtual/override/new keywords...
Bhushan,
Be careful before you consider an interviewer "stupid", although there are plent of them.
I will often ask "stupid" question to see how the candidate reacts...
Either that or I will ask questions which typically illicit "boiler plate" responses which are wrong....
1) What does the Dispose() method of a class do???
2) When is Dispose() called by the Runtime?
More than half of all candidates get either or both of these WRONG....
I don't know if the expression "Crazy Like a Fox" translates well into your native tongue, but it should be a "fun" one for you to research... :wave: :wave:
Re: About abstract/sealed/virtual/override/new keywords...
Hi.
The two questions that TheCPUWizard has put here, have to have some concrete and distinct way of answering them. I have come across a numerous answers that seems to be right, but you never know if they are 100%. Here is what I know:
=====================================================
Quote:
1) What does the Dispose() method of a class do???
It invokes the destructor/finalize method explicitly. There are certain situations when you might require to start the garbage collection explicitly. The dispose() method makes calls to the destructors or finalize() method. I do not know if framework calls Dispose() method implicitly? The very first time I saw a question about destructors in C#, I was surprised because I never knew about them. Then on, I understood that the destructors very much exist in C#, but they are controlled by Garbage Collectors unlike C++. So, all these things happening behind the scenes, what should be the simple answer to the above question that would best appease an interviewer?
Here is a link I found some good information on C# destructors:
Another random link tells us the following:
In C#, however, this syntax is simply a shortcut for declaring a Finalize() method that chains up to its base class. Thus, when you write:
Code:
~MyClass()
{
// do work here
}
the C# compiler translates it to:
Code:
protected override void Finalize()
{
try
{
// do work here
}
finally
{
base.Finalize();
}
}
=====================================================
Quote:
2) When is Dispose() called by the Runtime?
Normally Dispose() is called at the runtime by garbage collector. Initially, I read in a lot of places that the garbage collector frees the allocated memory in a random fashion. But later on as I came to know that it is called when, the system is running low on resources and GC has to free some of them. Further, as I read, I understood that the objects were freed in the reverse manner they were created. That means the objects that have been alive for a longer time took more efforts for GC in deleting than the ones that were recently created. I am not sure why this is true and how? Also, Dispose() can be explicitly called by the developer in certain situations as discussed in first Q.
=====================================================
Thankyou and Regards,
Bhushan.
Re: About abstract/sealed/virtual/override/new keywords...
Quote:
It invokes the destructor/finalize method explicitly.
Nope. The finalizer will only ever be called in the finalizer thread when the object is ready to be freed by the GC. The runtime will never call the Dispose method automatically.
Dispose is a user created, user callable method which is typically used to immediately release unmanaged resources as opposed to waiting for the GC to free the object.
Typically the finalizer is used to ensure that dispose is called, so the finalizer will typically call the dispose method. MSDN has good information on the finalize/dispose pattern.