Briefly explain the difference between Public (public), Friend (internal), and Private (private) access levels as they apply to user-defined types and members.

1 Answer

Answer :

In user-defined types, Public (public) classes can be instantiated by any element of the application. Friend (internal) classes can be instantiated only by members of the same assembly, and Private (private) classes can be instantiated only by themselves or types they are nested in. Likewise, a Public (public) member can be accessed by any client in the application, a Friend (internal) member can be accessed only from members of the same assembly, and Private (private) members can be accessed only from within the type. 

Related questions

Description : Briefly describe the three types of user-developed controls and how they differ.

Last Answer : The three types of user-developed controls are inherited controls, user controls, and custom controls. An inherited control derives from a standard Windows Forms control and inherits the ... inherit only generic control functionality. All specific functionality must be implemented by the developer.

Description : Briefly describe what members are, and list the four types of members.

Last Answer : Members are the parts of a class or a structure that hold data or implement functionality. The primary member types are fields, properties, methods, and events.

Description : Briefly highlight the differences between imperative and declarative security as they pertain to code access security.

Last Answer : Imperative security is implemented by calling methods of Permission objects in code at run time. Declarative security is configured by attaching attributes representing permissions to classes ... request assembly-wide permissions using the Assembly (assembly) directive with declarative security.

Description : Briefly contrast connected and disconnected data access in ADO.NET.

Last Answer : In ADO.NET, connected data access is available through the DataReader, which is a lightweight class designed to provide very fast and efficient data access. It is severely limited, however, in ... to update the database and keeping the connection open just long enough to execute those commands.

Description : Can the members of an interface be private?

Last Answer : No. 

Description : Briefly explain encapsulation and why it is important in object-oriented - programming.

Last Answer : Encapsulation is the principle that all of the data and functionality required by an object be contained by that object. This allows objects to exist as independent, interchangeable units of functionality without maintaining dependencies on other units of code.

Description : Briefly explain how to convert a string representation of a number to a numeric type, such as an Integer or a Double.

Last Answer : All numeric data types have a Parse method that accepts a string parameter and returns the value represented by that string cast to the appropriate data type. You can use the Parse method of each data type to convert strings to that type.

Description : Briefly explain what is meant by a reference type and a value type.

Last Answer : A value type holds all of the data represented by the variable within the variable itself. A reference type contains a reference to a memory address that holds the data instead of the actual data itself. 

Description : Can different assemblies share internal access? 

Last Answer : No

Description : Briefly describe how a class is similar to a structure. How are they different?

Last Answer : Both classes and structures can have members such as methods, properties, and fields, both use a constructor for initialization, and both inherit from System.Object. Both classes and structures can be ... are value types, and the memory that holds structure instances is allocated on the stack. 

Description : Briefly describe the five accessibility requirements of the Certified for Windows logo program.

Last Answer : The five requirements are o Support standard system settings. This requires your application to be able to conform to system settings for colors, fonts, and other UI elements. o Be ... information by sound alone. This requirement can be met by providing redundant means of conveying information.

Description : Briefly describe how to use the PrintDocument component to print a document. Discuss maintaining correct line spacing and multipage documents.

Last Answer : The PrintDocument class exposes the Print method, which raises the PrintPage event. Code to render printed items to the printer should be placed in the PrintPage event handler. The PrintPage event ... been printed, you must incorporate all logic for printing multiple pages into your event handler.

Description : What are the four major parts of a SQL SELECT statement? Briefly describe each one.

Last Answer : The four major parts of a SELECT statement are SELECT, FROM, WHERE, and ORDER BY. SELECT specifies the fields to be retrieved. FROM specifies the table from which the records are to be retrieved. WHERE ... the records to be retrieved, and ORDER BY allows you to specify a sort order for the records.

Description : Briefly describe an XmlDataDocument and how it relates to a DataSet.

Last Answer : An XmlDataDocument is an in-memory representation of data in a hierarchical XML format. Each XmlDataDocument is synchronized with a DataSet. Whenever changes are made to one object, the other is instantly updated. Thus, you can use the XmlDataDocument to perform XML manipulations on a DataSet.

Description : Briefly discuss the advantages and disadvantages of using typed DataSet objects.

Last Answer : Typed DataSet objects allow you to work with data that is represented as members of the .NET common type system. This allows your applications to be aware of the types of data returned in a DataSet and serves ... if you do not know the structure of your data, and can be used with any data source. 

Description : What are the two kinds of multidimensional arrays? Briefly describe each.

Last Answer : Multidimensional arrays can be either rectangular arrays or jagged arrays. A rectangular array can be thought of as a table, where each row has the same number of columns. Rectangular arrays with ... dimensional jagged array is like a table where each row might have a different number of columns.

Description : Briefly summarize the similarities and differences between arrays and collections.

Last Answer : Arrays and collections allow you to manage groups of objects. You can access a particular object by index in both arrays and collections, and you can use For Each Next (foreach) syntax to iterate ... Collections namespace can grow or shrink dynamically, and items can be added or removed at run time.

Description : Briefly describe how garbage collection works.

Last Answer : The garbage collector is a thread that runs in the background of managed .NET applications. It constantly traces the reference tree and attempts to find objects that are no longer referenced. When a nonreferenced object is found, its memory is reclaimed for later use.

Description : Briefly describe the major components of the .NET Framework and describe what each component does.

Last Answer : The .NET Framework consists of two primary parts: the common language runtime, which manages application execution, enforces type safety, and manages memory reclamation, and the .NET base class library, which consists of thousands of predeveloped classes that can be used to build applications.

Description : If a function is friend of a class, which one of the following is wrong ? (A) A function can only be declared a friend by a class itself. (B) Friend functions are not members of a class, they are ... are members of a class. (D) It can have access to all members of the class, even private ones.

Last Answer : (C) Friend functions are members of a class.

Description : Define what is the difference between Custom Control and User Control?

Last Answer : Custom Controls have compiled the code (DLLs), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time. Can be ... the toolbox and dragged - dropped from it. A User Control is shared among the single application files.

Description : What’s the difference between private and shared assembly? 

Last Answer : Answer: Privateassembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.

Description : An enterprise needs highly controlled storage and access to their databases as well as managing the infrastructure for web front ends and other applications. They have a large existing IT infrastructure and they ... to reduce cost? A. public cloud B. hybrid cloud C. private cloud D. internal cloud

Last Answer : hybrid cloud

Description : Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

Last Answer : The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.

Description : Why are there five tracing levels in System.Diagnostics.TraceSwitcher? 

Last Answer : The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.

Description : Are private class-level variables inherited? 

Last Answer : Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

Description : Where are private assemblies stored? 

Last Answer : Same folder as exe 

Description : Can base constructors can be private?

Last Answer : Yes

Description : What is private accessibility?

Last Answer : Access is restricted to within the containing class. 

Description : Are private class-level variables inherited? 

Last Answer : Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

Description : Can you override private virtual methods? 

Last Answer : No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access. 

Description : Are private class-level variables inherited? 

Last Answer : Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

Description : Can you override private virtual methods?

Last Answer : No. Private methods are not accessible outside the class.

Description : Can you override private virtual methods?

Last Answer : No, private methods are not accessible outside the class.

Description : Can we override the private virtual method in C#?

Last Answer : No. We can’t override private virtual methods as it is not accessible outside the class.

Description : Does the size of an array need to be defined at compile time.

Last Answer : No

Description : In terms of constructors, what is the difference between: public MyDerived() : base() an public MyDerived() in a child class?

Last Answer : Nothing

Description : Can properties have an access modifier?

Last Answer : Yes

Description : Can you use access modifiers with destructors? 

Last Answer : No

Description : Can events have access to modifiers?

Last Answer : Yes, you can have access to modifiers in events. You can have events with the protected keyword, which will be accessible only to inherited classes. You can have private events only for objects in that class.

Description : How do you enable your application to use .NET base class library members without referencing their fully qualified names?

Last Answer : Use the Imports keyword (Visual Basic .NET) or the using keyword (Visual C#) to make a .NET Framework namespace visible to your application. 

Description : Can properties hide base class members of the same name?

Last Answer : Yes

Description : What is the default accessibility for members of a struct? 

Last Answer : private

Description : What is the default accessibility for members of an interface?

Last Answer : public

Description : Explain how properties differ from fields. Why would you expose public data through properties instead of fields?

Last Answer : Properties allow validation code to execute when values are accessed or changed. This allows you to impose some measure of control over when and how values are read or changed. Fields cannot perform validation when being read or set.

Description : Describe the accessibility modifier “protected internal”. 

Last Answer : It is available to classes that are within the same assembly and derived from the specified base class.

Description : What is protected internal accessibility?

Last Answer : Access is restricted to types derived from the containing class or from files within the same assembly.

Description : What is internal accessibility?

Last Answer : A member marked internal is only accessible from files within the same assembly.

Description : Describe the accessibility modifier “protected internal”. 

Last Answer : It is available to classes that are within the same assembly and derived from the specified base class.

Description : Describe the accessibility modifier protected internal. 

Last Answer : It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).