Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?
C# Interview Questions and Answers
(Continued from previous question...)
63. Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?
There is no way to restrict to a namespace. Namespaces are never units of protection. But if you're using assemblies, you can use the 'internal' access modifier to restrict access to only within the assembly.
(Continued on next question...)
Other Interview Questions
- What's C#
- Is it possible to inline assembly or IL in C# code?
- Is it possible to have different access modifiers on the get/set methods of a property?
- Is it possible to have a static indexer in C#? allowed in C#.
- If I return out of a try/finally in C#, does the code in the finally-clause run?
- I was trying to use an out int parameter in one of my functions. How should I declare the variable that I am passing to it?
- How does one compare strings in C#?
- How do you specify a custom attribute for the entire assembly (rather than for a class)?
- How do you mark a method obsolete?
- How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?
- How do you directly call a native function exported from a DLL?
- How do I simulate optional parameters to COM calls?
- The C# keyword .int. maps to which .NET type?
- Which of these string definitions will prevent escaping on backslashes in C#?
- Which of these statements correctly declares a two-dimensional array in C#?
- If a method is marked as protected internal who can access it?
- What is boxing?
- What compiler switch creates an xml file from the xml comments in the files in an assembly?
- What is a satellite Assembly?
- What is a delegate?
- How does assembly versioning in .NET prevent DLL Hell?
- Which .Gang of Four. design pattern is shown below?
- In the NUnit test framework, which attribute must adorn a test class in order for it to be picked up by the NUnit GUI?
- Which of the following operations can you NOT perform on an ADO.NET DataSet?
- In Object Oriented Programming, how would you describe encapsulation?
- What do you know about .NET assemblies?
- What’s the difference between private and shared assembly?
- What’s a strong name?
- How can you tell the application to look for assemblies at the locations other than its own install?
- How can you debug failed assembly binds?
- Where are shared assemblies stored?
- How can you create a strong name for a .NET assembly?
- Where’s global assembly cache located on the system?
- Can you have two files with the same file name in GAC?
- So let’s say I have an application that uses MyApp.dll assembly ...
- What is delay signing?
- Is there an equivalent of exit() for quitting a C# .NET application?
- Can you prevent your class from being inherited and becoming a base class for some other classes?
- If a base class has a bunch of overloaded constructors ...
- I was trying to use an "out int" parameter in one of my functions. How should I declare the variable that I am passing to it?
- How do I make a DLL in C#?
- How do I simulate optional parameters to COM calls?
- Will finally block get executed if the exception had not occurred?
- What is the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? Does C# support try-catch-finally blocks?
- Is there regular expression (regex) support available to C# developers?
- Is there a way to force garbage collection?
- Does C# support properties of array types?
- What connections does Microsoft SQL Server support?
- What is a satellite assembly?
- How is method overriding different from overloading?
- When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?
- Why would you use untrusted verificaion?
- What is the implicit name of the parameter that gets passed into the class set method?
- How do I register my code for use by classic COM clients?
- How do I do implement a trace and assert?
- How do I create a multilanguage, multifile assembly?
- C# provides a default constructor for me. I write a constructor that takes a string as a parameter ...
- What is the equivalent to regsvr32 and regsvr32 /u a file in .NET development?
- Explain ACID rule of thumb for transactions.
- Where is the output of TextWriterTraceListener redirected?
- How do I create a multilanguage, single-file assembly?
- Why cannot you specify the accessibility modifier for methods inside the interface?
- Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?
- Why do I get a syntax error when trying to declare a variable called checked?
- Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
- What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile)?
- What does the keyword virtual mean in the method definition?
- What optimizations does the C# compiler perform when you use the /optimize+ compiler option?
- How can I create a process that is running a supplied native executable (e.g., cmd.exe)?
- What is the difference between the System.Array.CopyTo() and System.Array.Clone()?
- How do I declare inout arguments in C#?
- Is there a way of specifying which block or loop to break out of when working with nested loops?
- What is the difference between const and static read-only?
- What does the parameter Initial Catalog define inside Connection String?
- What is the difference between System.String and System.StringBuilder classes?
- What is the top .NET class that everything is derived from?
- Can you allow class to be inherited, but prevent the method from being over-ridden?
- Can you change the value of a variable while debugging a C# application?
- Are private class-level variables inherited?
- Can you inherit multiple interfaces?
- From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class?
- Which one is trusted and which one is untrusted?
- What namespaces are necessary to create a localized application?
- Does Console.WriteLine() stop printing when it reaches a NULL character within a string?
- What is the advantage of using System.Text.StringBuilder over System.String?
- What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
- Why do I get a security exception when I try to run my C# app?
- Is there any sample C# code for simple threading?
- What is the difference between // comments, /* */ comments and /// comments?
- What is the difference between and XML documentation tag?
- Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources).
- How do you inherit from a class in C#?
- How do I port "synchronized" functions from Visual J++ to C#?
- Can I define a type that is an alias of another type (like typedef in C++)?
- Is it possible to have different access modifiers on the get/set methods of a property?
- Is it possible to have a static indexer in C#?
- Does C# support #define for defining global constants?
- Does C# support templates?
- Does C# support parameterized properties?
- Does C# support C type macros?
- Can you store multiple data types in System.Array?
- Is it possible to inline assembly or IL in C# code?
- Can you declare the override method static while the original method is non-static?
- Does C# support multiple inheritance?
- Can multiple catch blocks be executed?
- Can you override private virtual methods?
- What is a pre-requisite for connection pooling?
- What is the data provider name to connect to Access database?
- Why does my Windows application pop up a console window every time I run it?
- What is the wildcard character in SQL?
- What is the role of the DataReader class in ADO.NET connections?
- What does the This window show in the debugger?
- Describe the accessibility modifier protected internal?
- What is an interface class?
- What is a multicast delegate?
- How does one compare strings in C#?
- What does assert() do?
- How do I get deterministic finalization in C#?
- How can I get around scope problems in a try/catch?
- Why do I get an error (CS1006) when trying to declare a method without specifying a return type?
- How do I convert a string to an int in C#?
- How do you directly call a native function exported from a DLL?
- What is the .NET datatype that allows the retrieval of data by a unique key?
- How do you specify a custom attribute for the entire assembly (rather than for a class)?
- What is the difference between a struct and a class in C#?
- What is the difference between the Debug class and Trace class?
- How can you overload a method?
- What debugging tools come with the .NET SDK?
- What does Dispose method do with the connection object?
- How do you generate documentation from the C# file commented properly with a command-line compiler?
- When you inherit a protected class-level variable, who is it available to?
- How can I get the ASCII code for a character in C#?
- How do I create a Delegate/MulticastDelegate?
- Is there an equivalent to the instanceof operator in Visual J++?
- How do destructors and garbage collection work in C#?
- My switch statement works differently! Why?
- How can I access the registry from C# code?
- How can you sort the elements of the array in descending order?
- How do you debug an ASP.NET Web application?
- How do you mark a method obsolete?
- How is the DLL Hell problem solved in .NET?
- What are the ways to deploy an assembly?
- Why does DllImport not work for me?
- What is a delegate?
- What is the difference between an interface and abstract class?
- What is an abstract class?
- Who is a protected class-level variable available to?
- Can you store multiple data types in System.Array?
- What’s the top .NET class that everything is derived from?
- What does the term immutable mean?
- What’s the difference between System.String and System.Text.StringBuilder classes?
- What’s the advantage of using System.Text.StringBuilder over System.String?
- What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
- How can you sort the elements of the array in descending order?
- What’s the .NET collection class that allows an element to be accessed using a unique key?
- What class is underneath the SortedList class?
- Will the finally block get executed if an exception has not occurred?
- What’s the C# syntax to catch any possible exception?
- Can multiple catch blocks be executed for a single try statement?
- Explain the three services model commonly know as a three-tier application.
- What is the syntax to inherit from a class in C#?
- Can you prevent your class from being inherited by another class?
- Can you allow a class to be inherited, but prevent the method from being over-ridden?
- What’s an abstract class?
- When do you absolutely have to declare a class as abstract?
- What is an interface class?
- Why can’t you specify the accessibility modifier for methods inside the interface?
- What happens if you inherit multiple interfaces and they have conflicting method names?
- What’s the difference between an interface and abstract class?
- What is the difference between a Struct and a Class?
- What’s the implicit name of the parameter that gets passed into the set method/property of a class?
- What does the keyword “virtual” declare for a method or property?
- How is method overriding different from method overloading?
- Can you declare an override method to be static if the original method is not static?
- What are the different ways a method can be overloaded?
- If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
- What’s a delegate?
- What’s a multicast delegate?
- How do you generate documentation from the C# file commented properly with a command-line compiler?
- What debugging tools come with the .NET SDK?
- What does assert() method do?
- What’s the difference between the Debug class and Trace class?
- Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
- Where is the output of TextWriterTraceListener redirected?
- How do you debug an ASP.NET Web application?
- What are three test cases you should go through in unit testing?
- Can you change the value of a variable while debugging a C# application?
- What is the role of the DataReader class in ADO.NET connections?
- What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
- What is the wildcard character in SQL?
- Explain ACID rule of thumb for transactions.
- What connections does Microsoft SQL Server support?
- Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted?
- What does the Initial Catalog parameter define in the connection string?
- What does the Dispose method do with the connection object?
- What is a pre-requisite for connection pooling?
- How is the DLL Hell problem solved in .NET?
- What are the ways to deploy an assembly?
- What is a satellite assembly?
- What namespaces are necessary to create a localized application?
- What is the smallest unit of execution in .NET?
- When should you call the garbage collector in .NET?
- How do you convert a value-type to a reference-type?
- What happens in memory when you Box and Unbox a value-type?
- Difference between directcast and ctype.
- An example of a ctype and directcast.
- ctype(123.34,integer) - should it throw an error? Why or why not?
- directcast(123.34,integer) - should it throw an error? Why or why not?
- Difference between a sub and a function.
- Explain manifest & metadata.
- Difference between imperative and interrogative code.
- Difference between value and reference type.
- What are the two kinds of properties.
- Explain constructor.
- Describe ways of cleaning up objects.
- How can you clean up objects holding resources from within the code?
- Which controls do not have events?
- What is the maximum size of the textbox?
- Which property of the textbox cannot be changed at runtime?
- Which control cannot be placed in MDI?
- What is the difference between proc. sent BY VAL and BY SUB?
|