473,382 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Abstract/Sealed method

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
10 3843
.... 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
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
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
He wan't talking about classes , right ?

May 20 '06 #5
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wayne Phipps | last post by:
I'm trying to get my head around objects and am asking for thoughts on this idea. If for example I were to implement a Person Object, there may be differnt Person objects representing people of...
33
by: Chris Capel | last post by:
What is the rationale behind the decision not to allow abstract static class members? It doesn't seem like it's a logically contradictory concept, or that the implementation would be difficult or...
14
by: Zeng | last post by:
Would somebody know when we should seal a class? Shouldn't all classes be open up for inheritance? Thanks!
6
by: steve bull | last post by:
I created a usercontrol class, RGBColorSpace, which is derived from an abstract class, ColorSpace, but when I try to click on the design panel for the control I get an error message "Unable to...
9
by: Kylin | last post by:
any better reason ? -- FireCrow Studio Kylin Garden EMail:gaotianpu@gmail.com ICQ:156134382
2
by: 0to60 | last post by:
I have a base class that defines a property. I'd like the the Get to be implemented by the base class and not overrideable. I would like the Set to be marked abstract, and thus needs to be filled...
4
by: Gert Kok | last post by:
The microsoft page http://msdn2.microsoft.com/en-us/library/9fkccyh4.aspx states: Remarks (nr 4) Virtual properties behave like abstract methods, except for the differences in declaration...
18
by: Vedo | last post by:
ref struct XXX abstract sealed { literal int A = 5; }; The definition above gives me the compiler warning "C4693: a sealed abstract class cannot have any instance members 'A'". The equivalent...
8
by: puzzlecracker | last post by:
0) What is the convention name for derived classes? 1) If we implement methods in abstract class, do we still need to declare them as abstract? 2) Are we allowed to override methods in derived...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.