You start by defining the Customer class as shown below:

You are currently in the process of creating a class that stores data about Domain.com’s customers.
Domain.com customers are assigned unique identifiers and various characteristics that may include
aliases, shipping instructions, and sales comments.
These characteristics can change in both size and data type. You start by defining the Customer class as shown below:
public class Customer{
private int custID;
private ArrayList attributes;
public int CustomerID {

You are currently in the process of creating a class that stores data about Domain.com’s customers.
Domain.com customers are assigned unique identifiers and various characteristics that may include
aliases, shipping instructions, and sales comments.
These characteristics can change in both size and data type. You start by defining the Customer class as shown below:
public class Customer{
private int custID;
private ArrayList attributes;
public int CustomerID {

A.
Use the following code to declare the FindAttribute method:
public T FindAttribute (T att){
//Find attribute and return the value
}

B.
Use the following code to declare the FindAttribute method:
public object FindAttribute (object att){
//Find attribute and return the value
}

C.
Use the following code to declare the FindAttribute method:
public T FindAttribute (T att){
//Find attribute and return the value
}

D.
Use the following code to declare the FindAttribute method:
public string FindAttribute (string att){
//Find attribute and return the value
}

Explanation:
This code declares the method FindAttribute and specifies an argument named att using the T placeholder as the argument and return data type. To ensure the FindAttribute method accepts arguments of different types, you should specify an argument using a generic placeholder. The argument att in this generic method will accept any valid data type and ensures type-safety by returning that same data type.
Incorrect Answers:
A: You should not use this code because it does not declare the placeholder T. when declaring a generic method, you have to use the bracketsto declare the place holder before using it.
B: You should not use this code because it does not guarantee type-safery.
D: You should not use this code because it will only accept a string argument and return a string argument.



Leave a Reply 2

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


Italo Pessoa

Italo Pessoa

the A item is wrong,
“A: You should not use this code because it does not declare the placeholder T(is declared). when declaring a generic method, you have to use the bracketsto declare the place holder before using it.”

seenagape

seenagape

I have the same idea. C