Depth. NET platform and C # programming "in-beta error correction records

Source: Internet
Author: User

1.. The core components of the NET Framework include (BD) (select two)

A.cts (common type System)

  B.CLR (Common language runtime,. NET basis)

C.CLS (Common Language Specification)

 D.FCL (frame class library,. NET a comprehensive object-oriented collection)

2. The following options in C # are said to be correct (B).

A. A class allows more than one parent class (single- sex)

B. The parent class contains public property A, and the subclass constructor can access a

C. The inheritance hierarchy of a class does not allow more than 3 layers (transitive)

D. If X is a subclass of Y, Z is the parent of Y, then Z is the subclass of X (x is a subclass, Y is the parent class, Y is a subclass of Z, and X is a subclass of Z)

3. In C #, the classes related to file operations are correct (AB) (select two).

A. The FileInfo class provides an instance method for manipulating files

B. The file class provides a static method for manipulating files

  C. Directory class provides an instance method of manipulating directories (directory classes provide static methods for manipulating directories)

 D. The DirectoryInfo class provides a static method of manipulating the directory (the DirectoryInfo class provides an instance method of manipulating the directory)

4. With respect to C # abstract classes and abstract methods, the following statement is wrong (C).

A. Using the abstract adornment when defining an abstraction class and an abstract method

B. Abstract methods cannot define method bodies

C. Abstract methods, like virtual methods, can be defined in all classes except sealed classes

D. Using abstract classes and abstract methods to achieve polymorphic

5. The following statement about List<t> is wrong (D).

The usage of the A.list<t> class is similar to ArrayList

B.list<t> has a greater degree of type safety than ArrayList

C. Accessing elements in list<t> is not required to do type conversions

T in d.list<t> can only be a value type (string also can)

6. In C #, if you want to implement a member of a parent class that is accessible in the parent class and its subclasses, and is inaccessible in his class, you should use the () adornment

The member is decorated with a character.

A.public

B.private

C.base

d.protected (Protected)

7. In C #, the constructors in the following teacher class are correctly spelled (AC) (select two).

A. Public Teacher () {}

B. private void Teacher () {} a privately Teacher method with null return value

C. Private Teacher (int id,string name) {}

D. Public int Teacher (int id,string name) {} return a parameter with a value of type int

8. In. NET, the following description error about the. NET Framework is (D)

A.. NET Framework can be installed on the Wiondows operating system

B.. NET Framework is running on top of the operating system

C.. NET Framework supports development languages such as c#,vb.net,c++

D.. NET applications cannot run on Linux

9. When creating a file stream in. NET, you need to specify the value of the file mode FileMode, and the following values for FileMode are interpreted correctly (AC)

(select two items)

A:create: Creates a new file with the specified name. If the file exists, overwrite the original

B:createnew: Create a new file. If it already exists, no processing is done (CreateNew creates a new file. If an exception occurs when the file exists, the hint file already exists. )

C:open: Opens a file. File must exist, otherwise error

D:openorcreate: Opens or creates a new file. If the file does not exist, create a new one without opening it (openorcreate: If the file does not exist, create a new file with the specified name and open it)

10. When working with files in. NET, you will often encounter garbled characters, the following options are correct in the garbled statement (C)

A: Handling garbled use encoding,encoding is an enumeration type

B: When writing the contents of the file to specify its encoding format, you can avoid garbled

C: When reading the file, specify the parsing file encoding format, can solve the garbled problem

D:encoding in the System.Data namespace

Analytical:

The use of files garbled nature is the file saved encoding and read the encoding method used inconsistent. Writing to the file specifies the encoding format, does not solve the problem, when reading the file, the specified and the text is saved in a consistent encoding format, no garbled; encoding in the System.Text namespace

11. In. NET, the following about the directory class and the DirectoryInfo class is correct (a)

The methods of the A:directory class are static and can be called directly

The methods of the B:directoryinfo class are static and can be called directly

Both the C:directory class and the DirectoryInfo class can use the exist () method to verify that the specified directory exists

The GetFile () method of the D:directory class returns an array of FileInfo objects under the specified directory

Analytical:

The methods of the directory class are static and can be called directly, and the method of the DirectoryInfo class is not static, so it is called by instantiation. Directory contains the exist () method, DirectoryInfo contains the exist property, and the GetFiles () method of the Directory class returns an array of file name strings in the specified directory

12. In the following C # code, the line fill (BD) does not go wrong. < select two Items >

Dictionary<int,string>dic=new dictionary<int,string> ();

Dic. ADD (1, "C#oop");

Console.WriteLine (_____________);

a:dic["C#oop"]

B:dic[dic. Count]

C:DIC[0]

D:DIC[1]

13. In C # code, the result of the following code output is (C)

Class Program

{

int num=10;

static void Main (String[]args)

{

Console.WriteLine (num++);

}

A:11

B:10

C: Compile Error

D: Run an error

  Analytical:

Static members can only be called through the class name, and only static members can be called in static methods.

Non-static members must be called through the object. So program compilation does not pass

14. In C #, use the collection initializer to initialize the collection using the correct (BC) < select two Items >

The A://se class is a class that has already been defined

List<se>list=new list<se> (New SE (), New SE ()); (Initialize multiple elements with {} instead of ())

The B://se class is a class that has already been defined

List<se>list=new list<se>{new SE (), New SE ()};

C:arraylist list=new arraylist{1,2};

D:arraylist list=new ArrayList () {1;2}; (multiple elements are separated by commas rather than semicolons)

15. In C #, the following code executes the result (B).

public struct Test

{

public int num;

}

public class Test1

{

public static void Change (test t1,ref test T2)

{

t1.num++;

t2.num++;

}

public static void Main ()

{

Test T1;

T1.num=1;

Test T2;

t2.num=2;

Change (T1,ref T2);

Console.Write (t1.num+ "," +t2.num);

}

}

a:1,1

b:1,3

c:2,2

d:2,1

  Analytical:

A ref-decorated value type is passed by reference type, and the struct is of value type;

The T1 is not modified with ref, the value does not change, T2 uses the ref modifier, the value changes

16. In C #, the Apple class is defined as a subclass of the fruits class, and the following statements cannot be used to convert the fruits type to Apple type (AD) < select two Items >

A:fruits fru=new Apple ();

Apple App=fru is Apple; (is used to determine)

B:fruits fru=new Apple ();

Apple App=fru as Apple;

C:fruits fru=new Apple ();

Apple app= (apple) Fru;

D:fruits fru=new Apple ();

Fru.                  Convert (Apple); (convert cannot be used here)

17. The following C # code will appear when the error occurs (BC) < select two Items >

A:arraylist a1=new ArrayList ();

A1. ADD (100);

A1. ADD (100);

B:hashtable ht=new Hashtable ();

Ht.         Add ("Zhang San", new Object ()); (Hashtable key appears duplicate)

Ht. Add ("Zhang San", new Object ());

C:list<string>list=new list<string> ();

String name=list[0]; (no subscript 0)

D:dictionary<string,object>dict=new dictionary<string,object> ();

foreach (Onject p in Dict. Values) {}

18. In C #, the method in the option is overloaded with the following method (D).

public void Add (int a,int b)

a.public int Add (int a,int b)

b.public void Addnum (double a,double b)

c.public void Add (int b,int a)

d.public void Add (int a,double b)

Analytical:

Method overloading means that the method name is the same, and the parameter type and the number of parameters are different, in the same class, constructors and ordinary methods can be overloaded

19: In C #, the following code runs as a result (a)

public class Fruit

{

public virtual void Show ()

{

Console.WriteLine ("Different flavors of fruit");

}

}

public class Lemon:fruit

{

public override void Show ()

{

Console.WriteLine ("Lemon is sour!") ");

}

}

Class Program

{

static void Main (String[]args)

{

  Fruit Lemon =new Fruit (); <new is the parent class object, so the method of the parent class is output >

Lemon. Show ();

}

}

A: Output "fruit tastes different"

B: Output "lemon is sour!"

C: The program is not error, but nothing is output

D: Program error, prompt object type inconsistent

20. Run the following C # code, then the output is (D)

public class Child

{

public virtual void like ()

{

Console.WriteLine ("Children like Toys");

}

}

public class Boy:child

{

public override void-like (string toys)

{

Console.WriteLine ("Boys Like" +toys);

}

}

Class Program

{

static void Main (String[]args)

{

Child child=new Child ();

Child. Like ("Toy Pistol");

}

}

A: Kids like toys

B: Boys Like toy pistols

C: Kids like toys

Boys Like toy Pistols

D: Program compile error, nothing output

  Analytical:

Boy.like (String) did not find a suitable method to override

Depth. NET platform and C # programming "in-beta error correction records

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.