PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You create components for Web-based client applications. You are creating a BankAccount class. The BankAccount class contains an AccountNumber property and a CreateAccount method. The CreateAccount method is used to create a new account. The method generates a unique random value for the actNumber field. You need to ensure that the BankAccount class is extendable, and that it serves as the base class for other derived classes. You also need to ensure that each derived class can have its own guidelines to generate account numbers in the CreateAccount method. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
public class BankAccount {
protected long actNumber;
public long AccountNumber {
get {
return actNumber;
}
}
public virtual BankAccount CreateAccount() {

}
}

B.
public class BankAccount {
private long actNumber;
public long AccountNumber {
get {
return actNumber;
}
}
public virtual BankAccount CreateAccount() {

}
}

C.
public class BankAccount {
protected long actNumber;
public long AccountNumber {
get {
return actNumber;
}
}
public BankAccount CreateAccount() {

}
}

D.
public class BankAccount {
private long actNumber;
public long AccountNumber {
get {
return actNumber;
}
}
public BankAccount CreateAccount() {

}
}


Leave a Reply