.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

Why can't you specify the accessibility modifier for methods inside the interface?

Posted By :Muthu     Posted Date :November 02, 2010    Points :10   Category :C# 
They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice,
you are not allowed to specify any accessibility, it's public by default.


You can also find related Interview Question to Why can''t you specify the accessibility modifier for methods inside the interface?  below: 

Why can't you specify the accessibility modifier for methods inside the interface

  
They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it's public by default. (More...)

Describe the accessibility modifier protected internal.

  
It's available to derived classes and classes within the same Assembly. (More...)

Can we have a variables inside the interface?

  
no, we can have only methods, properties, indexers and enums inside the interface. (More...)

Can we have a variables inside the interface?

  
no, we can have only methods, properties, indexers and enums inside the interface.
(More...)

Why struct is not used to hold entity instead of class?

(eventhough struct provides us properties, methods and interface support)

  
Struct is a value type and
Class is a reference type.

Struct is stored in Stack - so if you pass a struct as argument to method - a new struct will be created on stack and values will be copied - this is a time consumingp process in the order of n.

Class is stored in Heap - so the same reference can be passed to various methods without duplication. (More...)

Suppose you have created a WCF service. You have an interface stating your methods that must be exposed to the clients. But you have forgotten to specify "[OperationContract]" attribute in any of your method. What will happen ?

  
If you do not specify "[OperationContract] " in any of the methods in your interface then you will get the following error :-
IService1' has zero operations; a contract must have at least one operation



Here, Iservice is the name of my Interface. you can have your own name.
So, it is mandatory to label "[OperationContract] " attribute to at least one method while declaring your interface methods or ServiceContract.
(More...)

Can code inside multiple catch block be executed?

  
No, Code can not execute in mutiple catch block (More...)

What is the difference between interface and abstract class ?

  
a class may inherit several interfaces, a class may inherit only one abstract class (More...)

What is a modifier?

  
A modifier, also called a modifying function is a member function that changes the value of at least one data member. In other words, an operation that modifies the state of an object. Modifiers are also known as 'mutators'. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend