The method of constructing one class from another is called Inheritance.The derived class inherits all the properties and methods from the base class and it can add its own methods also.
2.Are constructors and destructors inherited ?
No3.Advantages of Inheritance.
a)Code re usability-Public and protected methods can be used in derived classes
b) Extensibility- base class can be extended as per business logic in derived classes.c)Polymorphism
4.What are diff types of inheritance?
a) Single inheritance --Class B is derived from base class A. A->B
b)Multiple inheritance ---Class C derives from both A and B. A,B->C
c)Multilevel inheritance--Class B derives from Class base class A.class C derives from B. A->B->C
d)Hybrid inheritance --class B and C derives from same base class A. A->B,C
5.Is multiple inheritance possible in C#.Why?
No. because
a)Its not supported by CLR since its support many diff language and not all languages can have multiple inheritance concept.
b)Because of the complexities involved where method name can clash when two diff classes have same method name.This is resolved by pointers in C++ but its not possible in c#.
Instead interfaces can be used to achieve the same.
6.Is circular inheritance possible. like A:B ,B:A ?
No
7.How do you prevent a class from being inherited ?
a)Make the class as sealed.
b)Add private constructors to the class.
8. Can derive class have public modifier when there are no modifiers specified on the base class?
No. bc derived class cannot be more accessible that base class.
9.why c# does not support inheritance by structure?
Because structures are mainly used for light weight process. And if they are allowed to be inherited then they have to act as base class which is not possible as they are value types.
10.Does structs inherit from interfaces?
Yes structs can inherit only from interface.
11.What do you mean by sealed keyword ?
If you mark a class as sealed it means that you cannot inherit from it but you can create objects of that class.
12.can you mark method as sealed ?
Yes.But for a method to be marked as sealed you need to have override keyword also.
13.what do you mean by upcasting and downcasting ?
class DerivedClass :BaseClass
Upcasting--assigning a derived class object to a base class.This is implicit.
BaseClass b= new DerivedClass.
Downcasting--assigning baseclass object to derived class. This is explicit and it throws run time error .
a)BaseClass b = new BaseClass()
DerivedClass d= b //will give compile time error.
b) d=(DerivedClass)b //will give runtime error.
c)b=d;
d=(DerivedClass)b;
d.method() //will always call derivedclass method
//there is no point in taking so much of pain and using this kind of code !!!
14.
Thanks for sharing...
ReplyDeleteTelugu Typing
very good
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHey Nice Post, Keep Updating more question and answers
ReplyDeletehttp://allittechnologies.blogspot.com/
C# (Sharp) Programming Interview Questions and Answers
ReplyDeletehttp://allinterviewquestionsandanswerspdf.blogspot.in/2016/06/top-110-c-sharp-programming-interview.html
If you are adopted and given a new name,and your adopted family passes away and leaves you land,and ND then you leaguely go back to your birth name are you still able to keep inheritance even though there are others who were born with the adopters last name
ReplyDeleteIf you are adopted and given a new name,and your adopted family passes away and leaves you land,and ND then you leaguely go back to your birth name are you still able to keep inheritance even though there are others who were born with the adopters last name
ReplyDeleteThank you so much for sharing this worth while to spent time on. You are running a really awesome blog. Keep up this good work
ReplyDeleteMobile Application Development Training in Chennai
The Dot Net Interview Questions shared are Very much useful My sincere thanks for sharing this post and please continue to share this kind of post
ReplyDeleteDot Net Training in Chennai
really you have been shared very informative post. before i read this blog i didn't have any knowledge about this but now i got some knowledge. so keep on sharing such kind of an interesting blogs.
ReplyDeletedot net training in chennai
thumba changide dhanyavadagallu
ReplyDeleteHello There,
ReplyDeleteHot! That was HOT! Glued to the References in C# Interview Questions your proficiency and style!x
I am trying to load a few lines ( many strings separated by a space) from a text file and break them into string tokens and store it as structure fields. This functions should be performed by the load items(item); function.
However there is an anomaly. When I print the structure fields to check if they have been loaded properly, it turns out they are not!. when I print structure fields outside the load items(item); function the fields do not seem to be stored properly in the array.
Thank you very much and will look for more postings from you.
Many Thanks,
Ashish
Very nice article Thanks for sharing
ReplyDelete.Net Online Training Hyderabad
Good. I am really impressed with your writing talents and also with the layout on your weblog. Appreciate, Is this a paid subject matter or did you customize it yourself? Either way keep up the nice quality writing, it is rare to peer a nice weblog like this one nowadays. Thank you, check also virtual edge and thanks for organizing the event
ReplyDeleteAda banyak visi tentang bagaimana mencapai pertanian berkelanjutan yang menyediakan makanan dan jasa ekosistem yang cukup untuk generasi sekarang dan masa depan di era perubahan iklim, peningkatan biaya energi, keresahan sosial, ketidakstabilan keuangan dan peningkatan degradasi lingkungan. Sistem pertanian baru yang mampu menghadapi tantangan dunia yang berubah dengan cepat membutuhkan minimal sepuluh atribut yang merupakan elemen penentu dari Pertanian Hijau. Tantangan utama adalah untuk mengidentifikasi serangkaian ambang yang harus dipenuhi oleh setiap strategi produksi pertanian, di luar itu tren yang tidak berkelanjutan yang disebabkan oleh teknologi pertanian akan mengarah pada fenomena titik kritis. Hanya gaya pertanian yang memenuhi kriteria ambang batas yang ditetapkan sambil memajukan masyarakat pedesaan menuju pangan, energi, dan kedaulatan teknologi yang akan dianggap sebagai bentuk Pertanian Hijau yang layak. Mempertimbangkan keragaman konteks ekologi, sosio-ekonomi, sejarah dan politik di mana sistem pertanian telah berkembang dan berkembang, adalah bijaksana untuk menetapkan seperangkat prinsip yang fleksibel dan dapat diadaptasi secara lokal dan batas-batas keberlanjutan dan ketahanan untuk agroekosistem masa depan segera. cek juga yukusaha dan Budidaya Cabe Rawit
ReplyDeleteReally you have been shared very informative post. before i read this blog i didn't have any knowledge about this but now i got some knowledge. so keep on sharing such kind of an interesting blogs.
ReplyDelete.net online training hyderabad
Visit us: dot net training
Very interesting blog.Thanks for sharing.
ReplyDeleteVisit us: ui path online training
Visit us: uipath training in hyderabad
Visit us: ui path course in bangalore
Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time.
ReplyDeleteVisit us: dot net training
Visit us: Dot Net Online Training Hyderabad
Visit us: .net online training india
Visit us: Dot Net Training Online India
This post is so usefull and informaive keep updating with more information.....
ReplyDeleteBest Data Science Courses in Bangalore
Data Science Institute in Bangalore
great post.
ReplyDeleteThanks for sharing.
CCNA course in Pune