C # basic concepts interview questions (updated)

Source: Internet
Author: User
Tags file transfer protocol

1. What are the three basic features of object-oriented?

A: encapsulation, Inheritance, and polymorphisn ).

Encapsulation: encapsulate objective objects into abstract classes. classes can only perform trusted class or object operations on their own data and methods to hide untrusted information.

Inheritance: it can use all functions of an existing class and extend these functions without re-writing the original class.

Polymorphism: Implements polymorphism in two ways: override and overload ).

2. What is the difference between Reference Type and Value Type?

A: The reference type is stored on the stack and contains a pointer to the instance. The default value is null;

The value type is stored on the stack and an actual value is stored. The default value is null.

C # The median type includes struct (numeric type, bool type, user-defined struct type), enumeration type, and empty type.

Reference types include arrays, user-defined classes, interfaces, delegates, objects, and strings.

3. What is the difference between structure (Struct) and Class?

A: The structure is of the value type. There is no default constructor, no destructor, no inheritance or inheritance, and no direct initialization of variables. You can directly declare variables without being New and not modifiers;

A class is a reference type. It has constructor and destructor. It can be inherited or inherited. It must be New before it can be used.

Similarities: multiple interfaces can be implemented, all of which are derived from the Object class.

4. C # MediumReference Type and Value Type)What are there?

Answer: value types: INTEGER (int), long (long), float, char, Boolean, and enum), structure (struct );

Reference types: class, string, interface, array (int [], string []), and arraylist ).

5. What are boxing and unboxing )?

A: boxing means converting the value type to the reference type, and unpacking means converting the reference type to the value type.

6. How can I determine an empty string?

A: string str = "";

1. if (str = "") is the slowest

2. if (str = string. Empty)

3. if (str. Length = 0) is the fastest

7. What is the layer-7 structure of the Open System Interconnection model?

A: From top down:

Application Layer (A), presentation layer (P), Session Layer (S), transmission layer (T), network layer (N), data link layer (DL), and physical layer (PH ).

8. How many common communication protocols do you know?

Answer: 1.TCP/ IP Protocol: (Transmission Control Protocol/Internet Protocol, Transmission Control Protocol/Internet Protocol). It consists of four layers: application layer, Transmission layer, Internet layer, and network interface layer.

2. SOAP Protocol: (Simple Object Access Protocol, Simple Object Access Protocol), XML-based Protocol.

3. User Data Protocol (UDP ).

4. HTTP (Hyper Text Transfer Protocol) is the foundation of the world wide web (www, world wide web) and belongs to the page object Protocol at the application layer.

5. FTP (File Transfer Protocol) is a Protocol provided by the Internet for accessing remote machines, allowing users to perform File operations between local and remote machines.

9. What are the differences between Virtual functions, Abstract classes, and interfaces in C?

A: virtual functions, which can be Override functions.

Abstract class, which cannot be directly instantiated.

Interface, only function definition, no function implementation, can only be inherited, cannot be instantiated class, equivalent to a pure abstract class, can implement multi-inheritance.

10. What is the difference between Const and Readonly?

A: The const keyword is used to declare the compile-time amount, and readonly is used to declare the run-time amount.

11. What are the differences between System. String and System. StringBuilder?

A: System. String is an unchangeable String. System. StringBuilder stores a variable string and provides some methods to modify the string.

Related Article

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.