Which code segment should you use?

You need to create a class definition that is interoperable along with COM.
You need to ensure that COM applications can create instances of the class and can call the GetAddress method.
Which code segment should you use?

You need to create a class definition that is interoperable along with COM.
You need to ensure that COM applications can create instances of the class and can call the GetAddress method.
Which code segment should you use?

A.
public class Customer {
string addressString;
public Customer(string address) {
addressString = address;
}
public string GetAddress() {
return addressString;
}
}

B.
public class Customer {
static string addressString;
public Customer() { }
public static string GetAddress() {
return addressString;
}
}

C.
public class Customer {
string addressString;
public Customer() { }
public string GetAddress() {
return addressString;
}
}

D.
public class Customer {
string addressString;
public Customer() { }
internal string GetAddress() {
return addressString;
}
}

Explanation:
The class should be declared with a parameter less constructor and the getAddress() method should be public.
A uses a constructor with Parameters.
B uses static members that are not supported in COM
D the method GetAddress() must be public to be accessible by COM.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


seenagape

seenagape

Correct answer is C