public static void Main() {
Coordinates c1 = new Coordinates();
Coordinates c2 = new Coordinates();
int x = 30;
c1.X = 30;
c2.X = 30;
Test(ref c1, c2, x);
Console.WriteLine("C1.X=" + c1.X.ToString() + ", C2.X=" + c2.X.ToString() + ", X=" + x.ToString());
Console.Read();
}
public static void Test(ref Coordinates Coord1, Coordinates Coord2, int X) {
Coord1 = new Coordinates();
Coord2 = new Coordinates();
Coord1.X = 0;
Coord2.X = 0;
X = 0;
}
What is the console output for the above sample code?
1 C1.X=30, C2.X=0, X=00
2 C1.X=0, C2.X=0, X=0
3 C1.X=30, C2.X=30, X=30
4 C1.X=0, C2.X=0, X=30
5 C1.X=0, C2.X=30, X=30
Which one of the following describes the OO concept of Aggregation?
1 A system of objects that are not related
2 A system of objects that are built using each other
3 A system of objects that define each other
4 A system of objects that implement each other
5 A system of objects inherited from each other
public interface ILocation {}
struct Point : ILocation {
public int Y;
public int X;
public Point() {
Y = 0;
X = 0;
}
public Point(int x, int y) {
Y = y;
X = x;
}
}
public void MovePoint() {
Point pt = new Point();
pt.X = 300;
pt.Y = 300;
}
Why does the sample code above NOT compile?
1 Structs cannot implement interfaces.
2 You can only initialize a struct variable using the "new" statement.
3 You cannot initialize a struct variable using the "new" statement.
4 Structs can only have a parameterless constructor.
5 Structs cannot have an explicit parameterless constructor.
Thursday, December 13, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment