NOTE: I need only the output. Please give both the answers. Thanks for your help. 5. Read the following code snippet: cl

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

NOTE: I need only the output. Please give both the answers. Thanks for your help. 5. Read the following code snippet: cl

Post by answerhappygod »

NOTE: I need only the output. Please give both theanswers. Thanks for your help.
5. Read the following code snippet:
class S {
public S() { Console.Write("S() ");}
}
class T : S {
public T() { Console.Write("T() ");}
}
class A {
public A() { Console.Write("A() ");}
}
class B : A {
public B() { Console.Write("B() ");}
}
class C {
private T t = new T();
public C() { Console.Write("C() ");}
}
class D : C {
private B x = new B();
public D() {Console.Write("D() "); } public static void Main() {
new D();
} } // Main方法和类D定义结束
The output will be:
6. Analyze the following code snippet:
public static void Main() {
string[] arr = {"One", "Two","Three",
"Four","Five","Six", "Seven"}; List<string> a1 = new List<string>();a1.AddRange(arr);
a1.Remove("Three");a1.RemoveAt(5);
a1.Insert(a1.IndexOf("Four"), "3"); a1.Insert(a1.Count, "OK");
a1.Sort((a,b) => -a.CompareTo(b));//所有元素排序:升还是降?
foreach(string s ina1) Console.Write("{0} ", s);
}
The output will be:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply