Assignment 3 20230412084042
Number of questions: 72 Full marks: 100 Answer time: 04-12 09:32 to 04-19 17:33 97.4 points
1. Multiple choice questions (72 questions in total, 100 points)
1. (Single-choice question) Regarding the use of interfaces, the wrong statement is _____________.
- A. Interfaces can be passed as parameters
- B. The interface can be used as the return value of the method
- C. The interface can be instantiated
- D. Implementing multiple interfaces at the same time is a disguised implementation of multiple inheritance
My answer: C: The interface can be instantiated; the correct answer: C: The interface can be instantiated;
1.3 points
2. (Single-choice question) The following statement is correct ________________.
- A. The loop formed by the do...while statement cannot be replaced by a loop formed by other statements
- B. The loop formed by the do...while statement can only be exited by the break statement
- C. The loop formed by the do...while statement ends the loop when the expression after the while is true
- D. The loop formed by the do...while statement, the expression after the while should be a relational expression or a logical expression
My answer: D: A loop composed of a do...while statement, the expression after the while should be a relational expression or a logical expression; the correct answer: D: A loop composed of a do...while statement, in The expression after while should be a relational expression or a logical expression;
1.3 points
3. (Single-choice question) The execution result of the statement "Console.WriteLine(typeof(void));" is ______________.
- A. System.Void
- B. null
- C. 0
- D. false
My answer: C:0; Correct answer: A:System.Void;
0 points
4. (Single-choice question) There is the following C# program:
using System;
{ class Program
{ static void Main()
{ int x=2,y=-1,z=2;
if(x<y)
if(y<0 ) z=0;
else z+=1;
Console.WriteLine("{0}",z);
}
}
}
- A. 3
- B. 2
- C. 1
- D. 0
My answer: B:2; Correct answer: B:2;
1.3 points
5. (Single-choice question) Which of the following statements about constants is incorrect is _____________.
- A. Constants must be initialized at declaration time
- B. After specifying the value of the constant, it can no longer be assigned and modified in the program
- C. Constants are always static, so the modifier static must be included when declaring
- D. The keyword const is used to declare constants
My answer: C: Constants are always static, so the modifier static must be included when declaring; Correct answer: C: Constants are always static, so the modifier static must be included when declaring;
1.3 points
6. (Single-choice question) In C#, attributes are classified from read/write characteristics, which can be divided into 3 types, except _____________.
- A. Read-only properties
- B. Write-only attributes
- C. Read/write properties
- D. Non-readable and non-writable attributes
My answer: D: Unreadable and unwritable attributes; Correct answer: D: Unreadable and unwritable attributes;
1.3 points
7. (Single-choice question)
The output of the following program is _______________.
using System;
namespace aaa
{ class Program
{ static void Main()
{ int i;
int[ ] a=new int[10];
for(i=9;i>=0;i--)
a[i]=10-i;
Console.WriteLine("{0},{1},{2}",a[2],a[5],a[8]);
}
}
}
- A. 2,5,8
- B. 7,4,1
- C. 8,5,2
- D. 3,6,9
My answer: C:8,5,2; Correct answer: C:8,5,2;
1.3 points
8. (Single-choice question)
There is the following C# program, input 9 from the keyboard during execution, the output result is _____________.
using System;
namespace aaa
{ class Program
{ static void Main()
{ int n;
n=int.Parse(Console.ReadLine());
if(n++<10)
Console.WriteLine("{0}",n);
else
Console.WriteLine("{0}",n--);
}
}
}
- A. 11
- B. 10
- C. 9
- D. 8
My answer: B:10; Correct answer: B:10;
1.3 points
9. (Single-choice question) In C#, which of the following descriptions about attributes is ____________.
- A. Attributes are fields modified with public keywords, and fields modified with public keywords can also be called attributes
- B. Attributes are a flexible mechanism for accessing field values. Attributes better implement data encapsulation and hiding
- C. To define a read-only property, just add the readonly keyword before the property name
- D. You cannot customize attributes in C# classes
My answer: B: Attributes are a flexible mechanism for accessing field values. Attributes better implement data encapsulation and hiding; Correct answer: B: Attributes are a flexible mechanism for accessing field values. Attributes are better implemented Encapsulation and hiding of data;
1.3 points
10. (Single-choice question) In C#, the field modified by the _____________ access modifier can only be accessed by the current assembly.
- A. public
- B. protected
- C. internal
- D. private
My answer: C:internal; Correct answer: C:internal;
1.3 points
11. (Single-choice question) Which of the following is an illegal real number constant is ____________.
- A. 200M
- B. 200D
- C. 200F
- D. 200R
My answer: D:200R; Correct answer: D:200R;
1.3 points
12. (Single-choice question) Which of the following statements is correct ________________.
- A. The loop formed by the do...while statement cannot be replaced by a loop formed by other statements
- B. The loop formed by the do...while statement can only be exited by the break statement
- C. The loop formed by the do...while statement ends the loop when the expression after the while is true
- D. The loop formed by the do...while statement, the expression after the while should be a relational expression or a logical expression
My answer: D: A loop composed of a do...while statement, the expression after the while should be a relational expression or a logical expression; the correct answer: D: A loop composed of a do...while statement, in The expression after while should be a relational expression or a logical expression;
1.3 points
13. (Single-choice question) Among the following types, the one that does not belong to the value type is ____________.
- A. Integer type
- B. Boolean type
- C. Character type
- D. Class type
My answer: D: class type; correct answer: D: class type;
1.3 points
14. (Single-choice question) In the definition of a class, the ______________ of a class describes the behavioral characteristics of objects of that class.
- A. Class name
- b. method
- C. The namespace it belongs to
- D. Private domain
My answer: B: method; correct answer: B: method;
1.3 points
15. (Single-choice question) The attribute count of the following class MyClass belongs to the ______________ attribute.
class MyClass
{
int i;
int count
{ get{ return; } }
}
- A. write only
- B. read-only
- C. read/write
- D. Not readable or writable
My answer: B: read-only; correct answer: B: read-only;
1.3 points
16. (Single-choice question) Which of the following statements about method overloading in C# is correct _________________.
- A. If two methods have different names but different numbers of parameters, they can constitute method overloading
- B. If two methods have the same name but different return value data types, they can constitute method overloading
- C. If two methods have the same name, but the data types of the parameters are different, then they can constitute method overloading
- D. If two methods have the same name and the same number of parameters, then they must not constitute method overloading
My answer: C: If two methods have the same name but different data types of the parameters, then they can constitute method overloading; Correct answer: C: If two methods have the same name but different data types of the parameters, then they can Constituent method overloading;
1.3 points
17. (Single-choice question) The following _____________ are not characteristics of constructors.
- A. The function name of the constructor is the same as the class name
- B. The constructor can be overloaded
- C. Constructors can take parameters
- D. You can specify the return value of the constructor
My answer: D: You can specify the return value of the constructor; Correct answer: D: You can specify the return value of the constructor;
1.3 points
18. (Single-choice question) In C#, which of the following statements about the number of parameters of the indexer is correct is _______________.
- A. Index can have no parameters
- B. An indexer can only have one parameter
- C. Indexers can have multiple parameters
- D. The indexer must have at least two parameters
My answer: C: The indexer can have multiple parameters; Correct answer: C: The indexer can have multiple parameters;
1.3 points
19. (Single-choice question) There are the following method definitions in the class MyClass:
public void testParams(params int[] arr)
{ Console.Write("Use Params parameters!"); }
public void testParams(int x,int y)
{ Console.Write("Use two integer parameters!"); }
Is there any ambiguity in the above method overloading? If not, the output of the following statement is ____________.
MyClass x=new MyClass();
x.testParams(0);
x.testParams(0,1);
x.testParams(0,1,2);
Console.WriteLine();
- A. Use the Params parameter! Use two integer parameters! Use the Params parameter!
- B. Use the Params parameter! Use the Params parameter! Use the Params parameter!
- C. Use Params parameters! Use two integer parameters! Use two integer parameters!
- D. has semantic ambiguity
My answer: A: Use the Params parameter! Use two integer parameters! Use the Params parameter! ; Correct answer: A: Use Params parameters! Use two integer parameters! Use the Params parameter! ;
1.3 points
20. (Single choice) The output of the following program is ____________.
using System;
namespace aaa
{
class Example1
{
static long sub(int x,int y)
{
return x*x+y*y;
}
public static void Main()
{
int a=30;
sub(5,2);
Console.WriteLine("{0}",a);
}
}
}
- A. 0
- B. 29
- C. 30
- D. No fixed value
My answer: C:30; Correct answer: C:30;
1.3 points
21. (Single-choice question) MyClass in C# is a custom class whose method is defined as public void Hello(){ ... }. Then create an object of this class, and use the variable obj to refer to the object, the statement is "MyClass obj=new MyClass();", then the statement that can access the Hello method of the class MyClass is ___________.
- A. obj.Hello();
- B. obj::Hello();
- C. MyClass::Hello();
- D. MyClass.Hello();
My answer: A:obj.Hello();; Correct answer: A:obj.Hello();;
1.3 points
22. (Single-choice question) Analyze the following C# statement, and notice that the class MyClass does not explicitly specify the access modifier:
namespace aaa
{
class MyClass
{
public class subclass
{ int i; }
}
}
The default access modifier for class MyClass is _____________.
- A. public
- B. protected
- C. private
- D. internal
My answer: D:internal; Correct answer: D:internal;
1.3 points
23. (Single-choice question) Analyze the following program:
public class MyClass
{
private string _sData="";
public string sData
{
set{ _sData=value; }
}
}
After successfully creating an object obj of this class in the Main function, the following ___________ statements are legal.
- A. obj.sData="It is funny!";
- B. Console.WriteLine(obj.sData);
- C. obj._sData=100;
- D. obj.set(obj.sData)
My answer: A:obj.sData="It is funny!";; Correct answer: A:obj.sData="It is funny!";;
1.3 points
24. (Single-choice question) The following _________________ keywords are used for the commission type.
- A. event
- B. this
- C. delegate
- D. value
My answer: C:delegate; Correct answer: C:delegate;
1.3 points
25. (Single-choice question) Which of the following statements about entrustment and entrustment type is __________________.
- A. A delegate is not a member of a class
- B. The delegate must be defined in the class
- C. To define a delegate, you need to use the delegate keyword
- D. A delegate type is a data type
My answer: C: You need to use the keyword delegate to define a delegate; Correct answer: C: You need to use the keyword keyword delegate to define a delegate;
1.3 points
26. (Single-choice question) Analyze the following sentences:
namespace NS
{
public delegate void Hello(string target);
}
What this statement does is _______________.
- A. A global method named Hello is defined in the NS namespace
- B. The prototype of the function Hello in the NS namespace
- C. A function pointer named Hello is defined in the NS namespace
- D. A delegate type named Hello is defined in the NS namespace
My answer: D: A delegate type named Hello is defined in the NS namespace; Correct answer: D: A delegate type named Hello is defined in the NS namespace;
1.3 points
27. (Single-choice question) There is the following C# code:
class App
{
public static void Main()
{
mydelegate p = new mydelegate(CheckStatus);
p("string...");
...
}
static void CheckStatus(string state)
{
Console.WriteLine(state);
}
}
where mydelegate is a ___________.
- A. Structural type
- B. Order Type
- c. function
- D. Class name
My answer: B: entrusted type; correct answer: B: entrusted type;
1.3 points
28. (Single-choice question) In C#, which of the following statements about namespaces is correct is ___________.
- A. Only one namespace can exist in a .cs file
- B. Namespaces cannot be nested
- C. Use private to modify the namespace, and its internal classes are not allowed to access
- D. Namespaces make code more organized and structured
My answer: D: The namespace makes the code more organized and the structure is clearer; the correct answer: D: The namespace makes the code more organized and the structure is clearer;
1.3 points
29. (Single-choice question) The following _____________ keywords are used to define events.
- A. delegate
- B. event
- C. this
- D. value
My answer: B:event; Correct answer: B:event;
1.3 points
30. (Single-choice question) An object that notifies other objects (subscribers) of an event is called the _____________ of the event.
- A. Broadcaster
- B. Notifier
- C. Issuer
- D. Subscribers
My answer: C: issuer; correct answer: C: issuer;
1.3 points
31. (Single-choice question) In C#, a class ____________.
- A. Can inherit multiple classes
- B. Can implement multiple interfaces
- C. There can be only one subclass in a program
- D. Only one interface can be implemented
My answer: B: Multiple interfaces can be implemented; Correct answer: B: Multiple interfaces can be implemented;
1.3 points
32. (Single-choice question) Which of the following statements about the inheritance mechanism is correct ____________.
- A. Any class can be inherited in C#
- B. A subclass can inherit multiple parent classes
- C. The object class is the base class of all classes
- D. Inheritance is transitive. If class A inherits class B and class B inherits class C, then class A also inherits class C
My answer: C: object class is the base class of all classes; correct answer: C: object class is the base class of all classes;
1.3 points
33. (Single choice) The ____________ keyword is used in C# to access the members of the base class from the derived class.
- A. new
- B. super
- C. this
- D. base
My answer: D:base; Correct answer: D:base;
1.3 points
34. (Single-choice question) In C#, to rewrite the virtual function of the base class in the derived class, it is required to use __________ in the declaration of the derived class.
- A. override
- B. new
- C. static
- D. virtual
My answer: A:override; Correct answer: A:override;
1.3 points
35. (Multiple choice)
There are the following programs:
using System;
namespace aaa
{
class A
{
public A()
{
Console.Write("A");
}
}
class B:A
{
public B():base()
{
Console.WriteLine("B");
}
}
class Program
{
public static void Main()
{
B b=new B();
}
}
}
The above code will output __________ in the console window after running.
- A. A
- B. B
- C. A B
- D. B A
My answer: C:AB; Correct answer: C:AB;
1.3 points
36. (Single-choice question) In the following description about abstract classes, the wrong one is ____________.
- A. An abstract class can contain non-abstract methods
- B. A class with an abstract method must be an abstract class
- C. Abstract classes cannot be instantiated
- D. An abstract class can be a sealed class
My answer: D: Abstract classes can be sealed classes; Correct answer: D: Abstract classes can be sealed classes;
1.3 points
37. (Single-choice question) In C#, the difference between an interface and an abstract base class is ____________.
- A. An abstract class can contain non-abstract methods, while an interface does not contain any method implementations
- B. Abstract classes can be instantiated, but interfaces cannot be instantiated
- C. Abstract classes cannot be instantiated, but interfaces can be instantiated
- D. Abstract classes can be inherited, but interfaces cannot be inherited
My answer: A: Abstract classes can contain non-abstract methods, while interfaces do not contain any method implementations; Correct answer: A: Abstract classes can contain non-abstract methods, while interfaces do not contain any method implementations;
1.3 points
38. (Single-choice question) Among the following statements about abstract classes and interfaces, the correct one is _____________.
- A. All methods in an abstract class are abstract methods
- B. A subclass inherited from an abstract class must implement all the abstract methods in its parent class (abstract class)
- C. There can be method implementations in interfaces, but no method implementations in abstract classes
- D. A class can inherit from multiple interfaces, and can also inherit from multiple abstract classes
My answer: B: A subclass inherited from an abstract class must implement all abstract methods in its parent class (abstract class); Correct answer: B: A subclass inherited from an abstract class must implement all abstract methods in its parent class (abstract class) All abstract methods of ;
1.3 points
39. (Single-choice question) In the definition of the following class MyClass, _____________ is a legal abstract class.
- A. abstract class MyClass{ public abstract int getCount(); }
- B. abstract class MyClass{ abstract int getCount(); }
- C. private abstract class MyClass{ abstract int getCount(); }
- D. sealed abstract class MyClass{ abstract int getCount(); }
My answer: A:abstract class MyClass{ public abstract int getCount(); }; Correct answer: A:abstract class MyClass{ public abstract int getCount(); };
1.3 points
40. (Single-choice question) Polymorphism refers to the way two or more different objects respond differently to the same message. Polymorphism in C# cannot be achieved through ___________.
- A. Interface
- B. Abstract class
- C. Virtual methods
- D. Sealed
My answer: D: sealed class; correct answer: D: sealed class;
1.3 points
41. (Single-choice question) Analyze the definition of the class MyClass in the following program:
class BaseClass
{
public int i;
}
class MyClass:BaseClass
{
public new int i;
}
Then the output of the following statement on the Console is _______________.
MyClass y = new MyClass();
BaseClass x = new BaseClass();
x.i = 100;
Console.WriteLine("x.i={0},y.i={1}",x.i,y.i);
- A. 0,0
- B. 100,100
- C. 0,100
- D. 100,0
My answer: D: 100, 0; Correct answer: D: 100, 0;
1.3 points
42. (Single-choice question) Among the differences between interfaces and classes, the correct one is ________________.
- A. Classes can be inherited, but interfaces cannot
- B. Classes cannot be inherited, but interfaces can
- C. Classes can inherit multiplely, but interfaces cannot
- D. Classes cannot inherit more than one, but interfaces can
My answer: D: Classes cannot inherit more, but interfaces can; Correct answer: D: Classes cannot inherit more, but interfaces can;
1.3 points
43. (Single-choice question) The declarations of the known interface IHello and classes Base and Drived are as follows:
interface IHello
{
void Hello();
}
class Base:IHello
{
public void Hello()
{
System.Console.WriteLine("Hello in Base!");
}
}
class Derived:Base
{
public void Hello()
{
System.Console.WriteLine("Hello in Derived!");
}
}
Then the output of the following statement in the console is ____________.
IHello x=new Derived();
x.Hello();
- A. Hello in Base!
- B. Hello in Derived!
- C. Hello in Base!Hello in Derived!
- D. Hello in Derived!Hello in Base!
My answer: B:Hello in Derived!; Correct answer: A:Hello in Base!;
0 points
44. (Multiple choice)
Define the following IPlay interface in C#, the correct code to implement this interface is ___________.
interface IPlay
{
void Play();
void Show();
}
- A.
class Teacher:IPlay
{
void Play(){ //Omit some codes }
void Show(){ //Omit some codes }
}
- B.
class Teacher:IPlay
{
public string Play(){ //Omit some codes }
public void Show(){ //Omit some code }
}
- C.
class Teacher:IPlay
{
public void Play();
public void Show(){ //Omit some code }
}
- D.
class Teacher:IPlay
{
public void Play(){ //Omit some codes }
public void Show(){ //Omit some code }
}
My answer: D:class Teacher:IPlay { public void Play(){ //Omit some codes} public void Show(){ //Omit some codes} };Correct answer: D :class Teacher:IPlay { public void Play (){ //Omit some codes} public void Show(){ //Omit some codes} };
1.3 points
45. (Single-choice question)
The output of the following program is ____________.
using System;
namespace aaa
{
public class Vehicle
{
private int speed=10;
public int Speed
{
get{ return speed; }
set
{
speed=value;
Console.WriteLine("No entry");
}
}
}
public class NewVehicle:Vehicle
{ public NewVehicle()
{
if(this.Speed>=20) Console.Write("Motor vehicle!");
else Console.Write("Non-motor vehicle!");
}
}
public class Program
{
public static void Main()
{
NewVehicle tong=new NewVehicle();
tong.Speed=30;
}
}
}
- A. It is forbidden to drive into non-motorized vehicles!
- B. Non-motorized vehicles! No entry
- C. No access to motor vehicles!
- D. Motor Vehicles! No Entry
My answer: B: Non-motorized vehicles! It is forbidden to drive in; the correct answer: B: Non-motorized vehicles! No entry;
1.3 points
46. (Single choice) The output of the following program is ____________.
using System;
namespace aaa
{
public class Person
{
private int age=0;
public int Age
{
get{ return age; }
set
{ if(value>=18) Console.WriteLine("Adult");
else Console.WriteLine("Non-adult");
age=value;
}
}
}
public class People:Person
{
public People()
{
Console.Write("Do not enter");
}
}
public class Program
{
public static void Main()
{
People wang=new People();
wang.Age=25;
}
}
}
- A. Non-adults are not allowed to enter
- B. Adults are not allowed inside
- C. No minors allowed
- D. No adults allowed
My answer: D: Do not enter adults; Correct answer: D: Do not enter adults;
1.3 points
47. (Single-choice question) Which of the following statements about indexers is incorrect is _____________.
- A. Indexers can be overloaded
- B. Indexers can only be designed when the class has an internal collection or array
- C. The name of the indexer is fixed as this
- D. The indexer can be static or instance
My answer: D: The indexer can be static or instance; Correct answer: D: The indexer can be static or instance;
1.3 points
48. (Single-choice question) Which of the following statements about constant fields is correct ________________.
- A. Objects of any reference type can be constant
- B. Constants are static members, so the static modifier must be used when declaring constants
- C. Constants must have their value set at compile time
- D. The value of the constant can be changed as needed while the program is running
My answer: C: The constant must set its value at compile time; Correct answer: C: The constant must set its value at compile time;
1.3 points
49. (Single-choice question) Which of the following statements about static methods is incorrect is ______________.
- A. Static methods do not operate on specific instances
- B. Static methods can only directly access static members
- C. Referencing this in a static method will cause a compile-time error
- D. Static methods are accessed through instances of the class
My answer: D: Static methods are accessed through instances of classes; Correct answer: D: Static methods are accessed through instances of classes;
1.3 points
50. (Single-choice question) Which of the following statements about instance methods is incorrect is __________________.
- A. Instance methods are accessed through classes
- B. Instance methods operate on a given instance of the class
- C. Instance methods can access static members and instance members
- D. On the instance where the instance method is called, the instance can be explicitly accessed through this
My answer: A: The instance method is accessed through the class; the correct answer: A: The instance method is accessed through the class;
1.3 points
51. (Single-choice question) Static methods cannot access ___________________.
- A. Static fields of the same type
- B. Same instance field
- C. Static field in another class
- D. An instance field in another class, but an object of this class must be created first, and then called by the object name
My answer: B: Instance fields of the same class; Correct answer: B: Instance fields of the same class;
1.3 points
52. (Single-choice question) Which of the following statements about constructors is incorrect is ________________.
- A. The name of the constructor is the same as the class name
- B. A constructor cannot declare a return type (neither can it use void), nor can it return a value
- C. Constructors can only be declared as public types
- D. You cannot explicitly call a constructor when creating an object
My answer: C: Constructors can only be declared as public types; Correct answer: C: Constructors can only be declared as public types;
1.3 points
53. (Single-choice question) Which of the following statements about static constructors is incorrect is ___________.
- A. A static constructor is used to implement the operations required to initialize an instance or object
- B. Static constructors are used to initialize any static data, or to perform specific operations that only need to be performed once
- C. A static constructor of a class is executed at most once in a given program
- D. The static constructor has neither access modifiers nor parameters
My answer: A: The static constructor is used to implement the operations required to initialize an instance or object; the correct answer: A: The static constructor is used to implement the operations required to initialize an instance or object;
1.3 points
54. (Single-choice question) Which of the following statements about destructors is correct is ________________.
- A. The destructor has no modifiers and no return value type, but it can have parameters
- B. The destructor cannot be inherited, but the destructor can be overloaded
- C. A class can have only one destructor
- D. A destructor must be called explicitly to destroy an instance of the class
My answer: C: A class can only have one destructor; Correct answer: C: A class can only have one destructor;
1.3 points
55. (Single-choice question) Which of the following statements about static members is incorrect is ________________.
- A. Static members belong to the class and are shared by all instances of the class
- B. Static members must be referenced by class name
- C. Static function code body can directly refer to both instance members and static members of the class
- D. When multiple instances of a class are created, its static fields occupy the same storage area in memory, that is, there is always only one copy
My answer: C: The static function code body can directly refer to both instance members and static members of the class; Correct answer: C: The static function code body can directly refer to both instance members and static members of the class ;
1.3 points
56. (Single-choice question) After calling the method, _____________ no longer exists.
- A. Formal parameters passed by value and their values
- B. Actual parameters passed by reference and their values
- C. Parameters modified with ref and their values
- D. Parameters modified with out and their values
My answer: A: The formal parameter and its value passed by value; the correct answer: A: The formal parameter passed by value and its value;
1.3 points
57. (Single-choice question) ________________ cannot be used directly in a static method.
- A. Static fields
- B. Instance fields
- C. Pass-by-value parameters
- D. Parameters passed by reference
My answer: B: Instance field; Correct answer: B: Instance field;
1.3 points
58. (Single-choice question) When calling a method to pass parameters, the _____________ of the formal parameters and actual parameters must match.
- A. type
- b. name
- c. address
- D. Access modifiers
My answer: A: type; correct answer: A: type;
1.3 points
59. (Single-choice question) Which of the following statements about the params parameter is incorrect is _____________.
- A. The parameter group must be last in the list
- B. The parameter group must be a one-dimensional array type
- C. The params modifier can be modified with out
- D. params must be the parameters passed by reference
My answer: C:params modifier can be modified with out; Correct answer: C:params modifier can be modified with out;
1.3 points
60. (Single-choice question) For the known class MyOwnClass, the following _____________ is the function header of a legal constructor.
- A. public static MyOwnClass(){ }
- B. public void MyOwnClass(){ }
- C. public int MyOwnClass(){ }
- D. public MyOwnClass(){ }
My answer: D:public MyOwnClass(){ }; Correct answer: D:public MyOwnClass(){ };
1.3 points
61. (Single-choice question) When no access modifier is defined, the default access modifier for members of a class is _________________.
- A. private
- B. public
- C. protected
- D. internal
My answer: A: private; Correct answer: A: private;
1.3 points
62. (Single-choice question) The accessibility of the access modifier protected internal is ___________.
- A. Unrestricted access
- B. Derived classes of assemblies
- C. Assembly and all derived classes of this class
- D. Only in this category
My answer: C: assembly and all derived classes of this class; correct answer: C: assembly and all derived classes of this class;
1.3 points
63. (Single-choice question) Which of the following statements about inheritance is correct _____________.
- A. Inheritance can avoid problems such as code duplication and related code maintenance
- B. A subclass of C# language can inherit multiple base classes (multiple inheritance)
- C. The C# language does not allow multiple interfaces to be implemented
- D. Subclasses can inherit the methods of the parent class, but cannot rewrite the methods of the parent class
My answer: A: Inheritance can avoid problems such as code duplication and related code maintenance; correct answer: A: Inheritance can avoid problems such as code duplication and related code maintenance;
1.3 points
64. (Single-choice question) Which of the following statements about sealed classes is correct ________________.
- A. A sealed class can be used as a base class
- B. A sealed class can be an abstract class
- C. A sealed class will never have any derived classes
- D. A sealed class or sealed method can be overridden or inherited
My answer: C: A sealed class will never have any derived classes; Correct answer: C: A sealed class will never have any derived classes;
1.3 points
65. (Single-choice question) Which of the following statements about the this keyword and the base keyword is incorrect is ____________.
- A. The this keyword is used to refer to the current instance of the class
- B. The base keyword is used to access the members of the base class from the derived class
- C. The this keyword cannot be used in static member functions
- D. The base keyword can be used in static member functions
My answer: D: The base keyword can be used in static member functions; Correct answer: D: The base keyword can be used in static member functions;
1.3 points
66. (Single-choice question) Which of the following statements about interfaces is incorrect is __________________.
- A. The interface cannot be instantiated
- B. All members declared in an interface are implicitly public and abstract
- C. The default access modifier for an interface is private
- D. Any non-abstract type that inherits an interface must implement all members of the interface
My answer: C: The default access modifier of the interface is private; Correct answer: C: The default access modifier of the interface is private;
1.3 points
67. (Single-choice question) To access the members of the base class in a derived class, you can use the keyword ____________.
- A. base
- B. this
- C. out
- D. external
My answer: A:base; Correct answer: A:base;
1.3 points
68. (Single-choice question) The virtual keyword cannot modify __________________.
- A. Static fields
- B. Attributes
- C. Indexer
- D. event
My answer: A: Static field; Correct answer: A: Static field;
1.3 points
69. (Single-choice question) Which of the following statements about virtual methods is incorrect is _______________.
- A. By default, C# methods are not virtual methods
- B. Non-virtual methods cannot be overridden
- C. The implementation of virtual members can be overridden in derived classes using the keyword override; or use the keyword new to override
- D. The virtual modifier can be used with static, abstract, private or override modifiers
My answer: D: The virtual modifier can be used with static, abstract, private or override modifiers; Correct answer: D: The virtual modifier can be used with static, abstract, private or override modifiers;
1.3 points
70. (Single-choice question) Virtual methods can use the following ________________ modifiers.
- A. public virtual
- B. public abstract virtual
- C. virtual abstract
- D. virtual override
My answer: A: public virtual; Correct answer: A: public virtual;
1.3 points
71. (Single-choice question) The following _____________ can become interface members.
- A. Indexer
- B. Constants
- C. Fields
- D. Destructor
My answer: A: Indexer; Correct answer: A: Indexer;
1.3 points
72. (Single-choice question) Which of the following statements about the event is incorrect is ________________.
- A. The event is a member of the class of the sender (producer)
- B. The event is a member of the receiving (consumer) class
- C. Events can be instanced or static
- D. An event is an object of a class that can contain multiple members
My answer: B: The event is a member of the receiving (consumer) class; correct answer: