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

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. 3. Read the following code snippet: pu

Post by answerhappygod »

NOTE: I need only the output. Please give both theanswers. Thanks for your help.
3. Read the following code snippet:
public class TestStatic {
private static intcx; //小写的(cx) static TestStatic() {
Console.Write("static TestStatic();"); cx = 0;
}
public static int CX { //大写的(CX)
get {Console.Write("get;"); return cx; } set { Console.Write("set;"); cx= value; }
}
public static voidMain() { Console.Write("Main();"); CX = 1;
Console.Write(CX + " ");
}
}
The output will be:
4. Analyze the following code snippet:
public classTestExchange { public static void Main() {
int i = 101, j =-99; Exchange(i, j);
Console.Write ("i ={0}, j = {1}; ", i, j); Exchange<int>(ref i, ref j);Console.Write ("i = {0}, j = {1}.", i, j);
}
static voidExchange(int x, int y) { int temp;
temp = x; x = y; y = temp;
}
static voidExchange<T>(ref T x, ref T y) where T : struct { T temp;
temp = x; x = y; y = temp;
}
}
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