Are you a senior programmer? Let's challenge it!

Source: Internet
Author: User
Tags try catch

Basic questions:

  1. What is the name of the implicit parameter for the set method that passes in an attribute?Value. Its type is the same as that of its attribute.
  2. How to Implement inheritance in C?Add a colon after the class name and the name of the base class.
  3. C # does it support multiple inheritance?Not supported. It can be implemented through interfaces.
  4. Where can I access the property/method modified by protected?It can be accessed in the subclass that inherits or indirectly inherits from this class.
  5. Will private members be inherited?Yes, but cannot be accessed. So it seems that they cannot be inherited, but they are actually inherited.
  6. Describe the modifier protected internal.Properties/Methods Modified by protected internal can only be accessed in its subclass in the same assembly.
  7. C # provides a default non-parameter constructor. When I implement another constructor with a parameter, I want to retain this non-parameter constructor. How many constructors should I write?Two. Once you implement a constructor, C # will no longer provide the default constructor. Therefore, you need to manually implement the non-parameter constructor.
  8. C # What is the common base class for all objects?System. object.
  9. What is the difference between heavy load and overwriting?Overload provides the implementation of calling different parameters for a method signature. Overwriting provides the implementation of modifying the behavior of the parent class method in the subclass.
  10. What does virtual mean in method definition?The virtual method can be overwritten by the quilt class.
  11. Can I override non-static methods into static methods?No. The signature of the overwriting method must be consistent with that of the overwriting method, except for changing virtual to override.
  12. Can I override a private virtual method?No. If a method is a virtual method, it should not be defined as private!
  13. Can a class be prevented from being inherited by other classes?Yes. Use the keyword sealed.
  14. Can a class be inherited, but cannot a method be overwritten?Yes. Mark this class as public and the method as sealed. (Note: This method must overwrite a virtual method in the parent class. Otherwise, sealed cannot be used)
  15. What is abstract class )?A class that cannot be instantiated. Abstract classes generally contain abstract methods. Of course, they can also be implemented. An inherited class can be instantiated only when abstract methods of all abstract classes are implemented.
  16. When must a class be declared as an abstract class?When this class contains abstract methods, or the class does not fully implement the abstract methods of the parent class.
  17. What is an interface?Class that only contains a total of abstract methods. These methods must be implemented in the subclass.
  18. Why cannot I specify a modifier for a method in an interface?The methods in the interface are used to define the contract for communication between objects. It is meaningless to specify the methods in the interface as private or protected. They are public methods by default.
  19. Can I inherit multiple interfaces?Of course.
  20. What if there are repeated method names in these interfaces?In this case, you can decide how to implement it. Of course, you must be very careful. However, there is no problem in the compilation process.
  21. What is the difference between an interface and an abstract class?All methods in the interface must be abstract and the access modifier of the method cannot be specified. Abstract classes can be implemented by methods, or you can specify the access modifier of methods.
  22. How do I distinguish between overload methods?Different parameter types, different parameter numbers, and different parameter order.
  23. What is the difference between const and readonly?The const keyword is used to declare the compilation frequency, and readonly is used to declare the runtime frequency.
  24. What is the difference between system. String and system. stringbuilder?System. String is an unchangeable string. System. stringbuilder stores a variable string and provides some methods to modify the string.


Advanced questions:

      1. What is the difference between thread and process ?. NET introduces the concept of application domain, so what is the difference between the three of them? Will application domain introduce some potential problems?

A process can be understood as a container that provides process space and the memory used by the thread is allocated in the process space. Each thread has its own stack. Appdomain is equivalent to a logical concept, which is equivalent to dividing some regions in the logic in the process. Therefore, threads can access other threads across domains.

      1. What is the difference between Windows Service and common EXE during execution?

Generally, the former has no interface, and a Windows Service server is responsible for maintenance, startup, and shutdown. EXE is maintained by the user and generally has an interface.

      1. What is the Windows Address Space that a process can access? Is it equal to the system's virtual memory size? What impact will these two aspects have on the system design?

A. It is related to the data bus. Generally, for 32-bit operating systems, the addressing space can reach 4 GB, so the address that a process can access is also 4 GB (but in fact, 2 GB is reserved for the operating system, 4 m is not accessible, and the remaining space is used by the process ).

B. Not equal to virtual memory.

C. The addressing space is related to the width of the Data Bus. The Virtual Memory consumes the CPU processing time. Because the conversion of internal and external memory is required.

      1. What is the difference between EXE and DLL? How should we choose to use them in system design?

A .. EXE has its own process space, DLL does not exist, dll can only be referenced, and the process space shared with Exe can be called and run (in fact, there is also the rundll32 command to start the DLL, this system command is essentially to provide process space for it ).

B. DLL is also called a dynamic link library. You can put the commonly used code and resources in the dynamic link library, so that there will be only one copy in the memory, saves memory space (different processes can be located in the specified DLL based on different relocation information ).

      1. What is the difference between the execution process of a common EXE and. Net EXE?

Normal EXE can be executed directly on the operating system, but. Net EXE requires JIT compilation in a timely manner and runs in a hosted environment (under the control of CLR ).

      1. What is a weak type and a strong type? In system design, which type should be considered first?

To some extent, the weak type allows different types of data to perform operations and operations on each other, but the strong type is not allowed, because the strong type performs the type check.

      1. What is the use of PDB files? What information does it contain?

The program database (PDB) File Stores debugging and project status information, which can be used to incrementally link the debugging configuration of the program.

      1. What is cyclomatic complexity? Why is it important?

Circle complexity, used to measure the number of branches of a program. In a normal method, the score should be limited to 5 or 6. If the number of branches is too large, it is best to break down the method to avoid badsmell.

      1. To create a critical section to access a variable, write a standard lock () and add double check.

If (m_instance! = NULL)

{

Lock (this)

{

If (m_instance! = NULL ))

{

// Do something

}

}

}

      1. Implements the standard dispose mode for an object.

Class myobject: idisposable

{

Public void dispose ()

{

// Do something

}

}

Is to implement the idisposable interface, and then implement custom Structure

      1. What is fulltrust? Does assembly in GAC have fulltrust?
      1. What is the following command? Gacutil/L | find/I "system"

The Global Assembly Cache tool allows you to view and manipulate the Global Assembly Cache and download the cached content.

      1. What is this command? Sn-t something. dll

Sn.exe provides options for key management, Signature generation, and signature verification.

      1. Which port must be opened for DCOM across firewalls? What is port 135 used?
      1. Is there any way to integrate with the existing unmanaged code? What should I consider during integration?
      1. What is OOP and SOA used?

Oop is a program programming architecture that contains components, encapsulation, inheritance, abstraction, and polymorphism.

SOA is a service-oriented architecture.

      1. How does xmlserializer work? What ACL permissions does a process need to run xmlserializer?

The ACL access control list.

      1. When should I use try catch during system design? When should I avoid using it?
      1. What is the difference between Debug. Write () and trace. Write? Where should they be used?

All are assertions. Debug. Write () is the debug version, which is not executed in the release version, but trace. Write is executed in the release version.

      1. What is the difference between debug build and release build? Is there any obvious difference in execution efficiency?

The debug build version contains some debugging information, which reduces the execution efficiency.

      1. Does JIT occur for assembly or method? To explain why. Net designers want to do this?
      1. Briefly describe the GC execution process.

When the memory is reduced to a certain extent, CLR starts garbage collection, recycles the non-referenced objects, and releases the occupied memory.

      1. How should I choose abstract class or interface?

Abstract classes can be implemented without interfaces. The interface can be inherited more than the abstract class.

      1. When designing a custom type, how should we choose whether to use value type or reference type?

The difference between the reference type and the value type is described. We can talk about the memory distribution and access efficiency.

      1. For value type and reference type, what are the default implementation methods of A. Equals (B?

The default value type is equal. The reference type is to compare whether two references point to the same object.

      1. Why does. net not provide the default deep copy? If necessary, how to implement deep copy?

Because deep copy involves the level of the copy, it is the level at which deep copy is required. In C #, you cannot directly override the memberwiseclone method. You can implement the iclone interface to implement custom deep copy.

      1. Compared with. NET 1.1, what support does. net2.0 provide to avoid excessive system overhead caused by boxing/unboxing?

Model.

      1. Is string value type or reference type? Why is the string object in. Net set to immutable?

Is a reference type. Because string objects appear frequently in the operating system, allocating an independent memory for each string will be a huge system overhead. Therefore, the string is set to immutable, which is a memory resident technology, essentially allowing the same string to access the same memory. For example, if S1 = "A", S2 = "B", both S1 and S2 are directed to the same memory block as "a". If S1 = "B" is modified ", s1 will no longer point to "A", but will open up another memory space for "B", so that S1 points to B (if there is another S3 = "B ", then S1 will point to the same "B" as S3, and S1 will no longer open up space ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.