C#
If a default value is assigned to any variable in a method's parameter list, what must all parameters to the right of that parameter have? An explicit cast. An implicit cast. A default value. A local keyword.
A default value.
What consists of abstract methods (and perhaps other members) that can be used by any class, as long as the class overrides the abstract method definitions? A class destructor. A properly implemented interface. A C# multifile assembly. A defined framework.
A properly implemented interface.
Classes that support simple data items each contain a method that provides the details of how items in the class compare to each other. What is the name of this method? CompareTo() IndexOf() Equals() Less()
CompareTo()
A GUI object, such as a Button, is represented as an object that cannot encapsulate any methods. True False
False
A declaration for a method that receives two or more arguments must list the type for each parameter separately only if the parameters have different types. True False
False
Overloaded methods sharing the same identifier must have the same return type. True False
False
To ensure that the original value of an argument passed to a method remains unchanged after returning from the method, you should use a reference parameter or an output parameter. True False
False
When you create an array of objects, the array holds the actual value of each of the objects. True False
False
You can overload an operator for a built-in data type. For example, you can change the meaning of + between two ints. True False
False
You cannot use the out or ref keywords when passing an array to a method. True False
False
What interface in C# contains the definition for the CompareTo() method that compares one object to another and returns an integer? IComparable CompareTo ICompareTo Comparable
IComparable
Where are the data components of a class that differ for each object stored? In variable unit states. Inside parent object relationships. Inside different object instantiations. Inside of instance variables.
Inside of instance variables.
What Visual Studio IDE feature can be used to discover information about methods you are using? CodeIntuit MagicMethod BitDissect IntelliSense
IntelliSense
When a method resides entirely within another method, and can only be called from within the containing method, what is the method known as? It is a scope function. It is a parent function. It is a client function. It is a local function.
It is a local function.
What happens when a method overrides another method? It overloads the original method, allowing for varying parameters. It instantiates that method and takes over its properties. It takes precedence over the original method, hiding it. It extends the original method, adding additional functionality.
It takes precedence over the original method, hiding it.
What do accessors do within the C# language? They define how an instantiation of a class behaves. They specify the statements that execute when a class's fields are accessed. They control access to the various properties of a class. They provide access to a field of a class.
They specify the statements that execute when a class's fields are accessed.
If you don't write a constructor for a class object, C# writes one for you. True False
True
Only nonstatic methods receive a this reference. True False
True
When you use a reference parameter, any passed variable must have an assigned value. True False
True
How can you avoid throwing an exception during data conversion when a value cannot be converted to an appropriate type? You can use the TryParse() method to attempt conversion, or assign a 0 to the variable if it is not possible. You can use the Parse() method, which may result in garbage being returned. You can use the ReadLine() method to convert the data to a string. You can use the Convert() method to force the conversion.
You can use the TryParse() method to attempt conversion, or assign a 0 to the variable if it is not possible.
What statement regarding the use of destructors is accurate? A destructor performs actions when a class is instantiated. You cannot provide any arguments to a destructor. A destructor must be explicitly created. To declare a destructor, you must use a dash - followed by the class name.
You cannot provide any arguments to a destructor.
Besides being known as a class client, what is a class that instantiates objects of another prewritten class known as? a class instantiation a class user a class state a server class
a class user
What is a method that uses another method considered to be? a method peer a server method a client of the other method a method pair
a client of the other method
What optionally declared method modifier can set limits as to how other methods are able to use the method? type protection qualifier accessibility
accessibility
What is a method considered to be when there is a potential for a situation in which the compiler cannot determine what method to use? overloaded hidden polymorphic ambiguous
ambiguous
What kind of property is one in which the code within the accessors is created automatically? auto-implemented property dynamic property polymorphic property abstract property
auto-implemented property
What term is used to describe any device you can use without knowing how it works internally? interface method white box black box
black box
When naming an argument in a method call using its parameter name, what must come before the value? semicolon colon dot comma
colon
As an alternative to repeating code in multiple constructors, what can be used to indicate that another instance of a class constructor should be executed before any statements in the current constructor body? constructor initializer value constructor parameterless constructor default constructor
constructor initializer
What kind of constructor takes no arguments whatsoever? default constructor construct initializer object constructor construct array
default constructor
What contains the actions you require when an instance of a class is destroyed, such as when the instance goes out of scope? class constructor constructor initializer destructor parameterless constructor
destructor
Arrays, like all objects, are passed by value. True False
false
The type of an argument in a method call must exactly match the type of the corresponding parameter specified in the method declaration. True False
false
What is another name used for instance variables in order to help distinguish them from other variables you might use? states instantiations fields relationships
fields
A parameter within a method header that accepts a value is considered to be what type of parameter? local parameter global parameter formal parameter actual parameter
formal parameter
What are methods with identical names that have identical parameter lists but different return types? overloaded methods related methods illegal methods applicable methods
illegal methods
What are methods with identical names that have identical parameter lists but different return types? related methods overloaded methods illegal methods applicable methods
illegal methods
A parameter that is undeclared and that gets its value automatically is considered to be what type of parameter? explicit implicit instance property
implicit
A parameter that is undeclared and that gets its value automatically is considered to be what type of parameter? property explicit instance implicit
implicit
Using private fields within classes is an example of what feature found in all object-oriented languages? information hiding polymorphism inheritance overloading
information hiding
What class access modifier should you utilize to limit access to the assembly (a group of code modules compiled together) to which the class belongs? internal private protected public
internal
The process of calling a method's name and using the method to perform a job for a class is also known by what term? instantiating the method inheriting the method invoking the method overloading the method
invoking the method
To more easily incorporate methods into a program, it is common practice to store methods in their own classes and files. Then you can add them into any application that uses them. What is the resulting compound program called?
multifile assewmby
What will a Click() method that responds to button clicks be by default, due to the fact that it is associated with an object that is a Form?
nonstatic
What type of arguments are ignored for betterness purposes on argument conversions? default arguments local arguments explicit arguments optional arguments
optional arguments
What type of parameter to a method will have a value automatically supplied if you do not explicitly send one as an argument? actual parameter value parameter default parameter optional parameter
optional parameter
What modifier is used to indicate that a parameter is used for output? params out ref get
out
For the sake of convenience, what parameter type can be used when the variable to be passed does not have an assigned value at the time the method is called? reference parameter mandatory parameter value parameter output parameter
output parameter
What technique allows for the ability to write multiple versions of a method using the same method name? overloading implementation hiding inheriting interfacing
overloading
What is the name for a variable that holds data passed to a method when it is called? element parameter declaration literal
parameter
What should you utilize when you don't know how many arguments you might eventually send to a method? parameter array output parameter reference parameter value parameter
parameter array
What is another name for unnamed method arguments? default arguments optional arguments positional arguments self-documenting arguments
positional arguments
If no method access specifier is defined for Main(), what will it be by default? private inherited static public
private
What accessibility modifier limits method access to the class that contains the method? protected internal private protected internal
private
What class access modifier can be used to indicate that access to the class is limited to the class and to any classes derived from the class? internal private public protected
private
When you place a button named okButton on a Form in the IDE and double-click it, what method header is generated automatically? private void okButton_Click(object sender, EventArgs e) public void okButton_Click(object sender, EventArgs e) static void okButton_Click(object sender, EventArgs e) private int okButton_Click(object sender, EventArgs e)
private void okButton_Click(object sender, EventArgs e)
What accessibility modifier allows access to a method from other classes? protected private public protected internal
public
What class access modifier means that access to the class is not limited? protected internal private public
public
What type of parameter requires that the argument used to call the method must have an assigned value? optional formal reference output
reference
On occasion, you might want a method to be able to alter a value you pass to it. What type of parameter should you use in this case? value parameter optional parameter global parameter reference parameter
reference parameter
What statement is used to cause a value to be sent back to the calling method? break result continue return
return
Even though you can't specify this modifier for a named constant within a class, what is the effective access modifier for the constant? static private public internal
static
What keyword modifier indicates that a method can be called by referring to the class rather than an object from the class? static internal nonstatic protected
static
What is the return type of the ReadLine() method call? bool Object string int
string
A method can return, at most, one value to a method that calls it. True False
true
If you do not provide an accessibility modifier for a method, it is private by default. True False
true
A formal parameter that receives a copy of the value passed to it is an example of what type of parameter? input value output reference
value
What type of parameter can be given a default value? value parameter array parameter output parameter reference parameter
value parameter
What type of parameter requires you to indicate the parameter's type and name, and the method receives a copy of the value passed to it? output parameter input parameter reference parameter value parameter
value parameter
Predefined types such as int, double, and char are all examples of what component of the C# language? reference types value types output types pointer types
value types
What statement regarding overloading methods is accurate? The compiler is able to discern which method to use based on the arguments you supply for a method call. An overloaded method must have parameters. When you create overloaded methods, you write multiple methods with different names but the same parameter list. When you overload a method, the number of parameters must be the same, but the types can be different.
The compiler is able to discern which method to use based on the arguments you supply for a method call.
How are the parameters for a Click() method received? The method must be passed the parameters by reference. The method must be called manually by another method. The method receives the parameters automatically when the corresponding Button is pressed. The method does not accept any parameters.
The method receives the parameters automatically when the corresponding Button is pressed.
A method's name and parameter list both constitute what component of the method? The return type for the method The method's type. The method's signature. The method stamp.
The method's signature.
Variables and constants that are declared within a method are only available until the end of the method. Why is this? The variables utilize defined locality. The variables are not configured for accessibility. Variables do not support nesting in C#. The method's variables exist within a scope, and are only visible within the method.
The method's variables exist within a scope, and are only visible within the method.
What are the set of attributes of an object's instance variable known as? The object's class instantiation. The object's relationship. The object's fields. The object's state.
The object's state.
In C#, what can be done to ensure that a parameter for a method is required in every method call? The parameter can be specified as mandatory. The parameter should be hard coded. The code calling the method is responsible for ensuring the parameter is passed when the method is called. The parameter should be specified as a constant in the class.
The parameter can be specified as mandatory.
When adding optional parameters in a parameter list, what is a valid requirement? The parameters must be defined globally. The parameters must appear to the right of all mandatory parameters. The parameters must have constant values. The parameters must all be placed locally.
The parameters must appear to the right of all mandatory parameters..
When declaring a method, how any params keywords are permitted? There is no limit to the use of the keyword. Only as many as there will be arguments. Two, provided there is a nested method. Only one params keyword is permitted.
Only one params keyword is permitted.
The number of arguments does not need to match the number in the parameter list when you use ____.19. When can a method be called with less arguments than exist in the parameter list for the method? Only when the parameters are marked as non-critical parameters. Only when scope relaxation is used to allow global variables. Only when default arguments are defined for the method. Only when value parameters are passed by other parts of the program.
Only when default arguments are defined for the method.
Under what circumstances will a method receive the actual memory address of a passed array, and have access to the actual values in the array elements? Only when the array is inherited. Only when it is passed by reference. Only when it is passed by value. Only when the array is within the method's scope.
Only when it is passed by reference.
Under what circumstances can you return a reference from a method? Only when the method performing the return is a static type method. Only when it is safe to return, such as returning a reference from a method if the reference was passed into the method. Only when the reference is for an array defined within the method's scope. Only when a method is returning optional parameters with known values as the reference.
Only when it is safe to return, such as returning a reference from a method if the reference was passed into the method.
When a variable or constant is required by multiple methods in a GUI program, where should it be defined? Inside a nested method shared by both methods. Inside of an inherited class. Inside one of the methods used by the GUI. Outside of the methods, but inside of the Form class shared by both methods.
Outside of the methods, but inside of the Form class shared by both methods.
What statement regarding reference parameters is accurate? Reference parameters occupy their own memory locations. Reference parameters act as aliases, or pseudonyms, for the same memory location occupied by the values passed to them. The params keyword is used to indicate a reference parameter. When you declare a reference parameter in a method header, the argument used to call the method does not require a value.
Reference parameters act as aliases, or pseudonyms, for the same memory location occupied by the values passed to them.