Question: In C# The interface object cannot method members, just member data. True False 1 points QUESTION 7 Given the following code snippet, public class AnyClass

In C#

The interface object cannot method members, just member data.

True

False

1 points

QUESTION 7

Given the following code snippet, public class AnyClass { private T[ ] items; private int loc = 0; public AnyClass (int size) { items = new T[size]; } public T RemoveItem( ) { return items[--loc]; } public void AddItem(T anItem) { items[loc] = anItem; loc++; } } if an object named gs had been instantiated of AnyClass, how would you invoke the RemoveItem( ) method if the T is a string?

WriteLine(gs.Remove( ));

WriteLine(gs.Remove(string));

WriteLine(string.Remove(gs));

string aValue = gs.Remove(string);

1 points

QUESTION 8

Given the following code snippet, public class AnyClass { private T[ ] items; private int loc = 0; public AnyClass (int size) { items = new T[size]; } public T RemoveItem( ) { return items[--loc]; } public void AddItem(T anItem) { items[loc] = anItem; loc++; } } if an object named gs had been instantiated of AnyClass, how would you invoke the AddItem( ) method if the T is a string?

gs.AddItem(string someValue);

gs.AddItem(an example);

string someValue = gs.AddItem( );

gs.AddItem(45);

1 points

QUESTION 9

Given the following code snippet, public class AnyClass { private T[ ] items; private int loc = 0; public AnyClass (int size) { items = new T[size]; } public T RemoveItem( ) { return items[--loc]; } public void AddItem(T anItem) { items[loc] = anItem; loc++; } } what best describes the code snippet?

AnyClass is a generic class

T is a placeholder indicating any type can be used

AnyClass can not be instantiated without given a value for its size

All of the above are correct

1 points

QUESTION 10

Which of these names must be used as a type indicator for a generic class?

K

N

T

none of the above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!