By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,467 Members | 1,553 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,467 IT Pros & Developers. It's quick & easy.

Abstract/Sealed method

P: n/a
TJM
Hi,

Is it possible to have a method sealed and abstract at the same time? MSDN
states clearly that this is not allowed for classes but it does not mention
it for methods. I tried with a simple example and the compiler would not
allow me to compile, however in a recent interview, I was asked this
question and the interviewer claimed that this is used in certain
situations! I am baffled!

Thanks,
TJM
May 20 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
.... how can a method be sealed (you cannot override it any further) and
abstract (you must override it) ? It's a contradiction.

If the interviewer was not mentioning ,and you misunderstood , the
combination of sealed override (which is the only way to apply sealed
in a method) then he was one of the usual managers.

Tasos

May 20 '06 #2

P: n/a
TJM
Tasos,

I am sure I did not misunderstand because I gave the same argument as you
did. But he insisted that this is possible!

TJM

"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
... how can a method be sealed (you cannot override it any further) and
abstract (you must override it) ? It's a contradiction.

If the interviewer was not mentioning ,and you misunderstood , the
combination of sealed override (which is the only way to apply sealed
in a method) then he was one of the usual managers.

Tasos

May 20 '06 #3

P: n/a
Be happy then if they don't offer you a position. :) The guy was the
typical manager in the typical company :)

Tasos

May 20 '06 #4

P: n/a
He wan't talking about classes , right ?

May 20 '06 #5

P: n/a
Because even if MSDN states that, it's a valid MSIL construct in .net 2
to enable static classes ... But for methods it's not valid.

May 20 '06 #6

P: n/a
A note ... if the guy was talking about classes in .NET 2 then he is
right in a case (altough it's kind of stupid to ask such a question
because it's a tiny detail).

I think that it is a custom in interviews to ask far-fetched questions
just to bring the candidate to a difficult position.

May 20 '06 #7

P: n/a
On Sat, 20 May 2006 10:23:14 -0400, "TJM" <tm******@cybiz.com> wrote:
Tasos,

I am sure I did not misunderstand because I gave the same argument as you
did. But he insisted that this is possible!

TJM

"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11*********************@i40g2000cwc.googlegr oups.com...
... how can a method be sealed (you cannot override it any further) and
abstract (you must override it) ? It's a contradiction.

If the interviewer was not mentioning ,and you misunderstood , the
combination of sealed override (which is the only way to apply sealed
in a method) then he was one of the usual managers.

Tasos


You can't create a sealed abstract class yourself, but I've heard that
the C# compiler compiles static classes as sealed abstract
somewhere... is that possible?

In the beta the was such a thing as sealed abstract :)
http://www.agiledeveloper.com/blog/P...d0d7e201e.aspx


--
Ludwig Stuyck
http://www.coders-lab.be
May 20 '06 #8

P: n/a
That's the fact. But it's down to MSIL (regarding C# compilation) ... I
don't know if it can happen to other languages .

May 20 '06 #9

P: n/a
TJM

Do you mean that it is possible to have a static abstract sealed class?
And if yes, what is it used for?

"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
Because even if MSDN states that, it's a valid MSIL construct in .net 2
to enable static classes ... But for methods it's not valid.

May 20 '06 #10

P: n/a
You can't have a sealed abstract class (in C#). The compiler compiles
the static class to a "sealed abstract class" construct.

May 20 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.