A method that does not return any value on exit, ____. Select one: a. must be ca
ID: 671689 • Letter: A
Question
A method that does not return any value on exit, ____.
Select one:
a. must be called with the void keyword
b. cannot include the return keyword
c. must be defined to have a void return type
d. is not allowed in C#
Question 2
A property resembles a ____, but is more closely aligned to a ____.
Select one:
a. data field, method
b. method, data field
c. object, mutator
d. mutator, accessor
Question 3
Console.WriteLine("Final Grade = {0:N2}",
CalculateGrade(90, 75, 83));
In the statement above, CalculateGrade(90, 75, 83) is ____.
Select one:
a. a method call
b. a method declaration
c. an identifier for the class
d. a parameter for the WriteLine() method
Question 4
Constructors should be defined with a ____ access modifier.
Select one:
a. public
b. private
c. protected
d. static
Question 5
Constructors ____.
Select one:
a. can be overloaded.
b. do not have to be written.
c. do not return a value.
d. all of the above.
Question 6
In order to provide a new definition for the ToString() method, ____.
Select one:
a. it must be defined using the new operator.
b. there must be at least one constructor defined.
c. use the keyword override in the heading
d. both mutators and accessors must have been defined.
Question 7
In order to test a class, ____.
Select one:
a. a different class is needed.
b. invoke instance methods using
the objects you construct.
c. use the properties to assign and retrieve values.
d. all of the above.
Question 8
Instance methods are ____.
Select one:
a. nonstatic methods.
b. also called class methods.
c. defined in the Main() method.
d. defined outside of the class.
Question 9
public static void Main()
The access modifier in the heading above is the keyword ____.
Select one:
a. public
b. static
c. void
d. Main()
Question 10
The definition of the method ____.
Select one:
a. is the same as the heading for the method
b. is the body of the method
c. includes everything between the curly braces
d. includes the heading and the body
Question 11
The first line of a method is called the ____ of the method.
Select one:
a. signature
b. definition
c. heading
d. declaration
Question 12
The following members of the Math class, (Round(), Max(), Exp()), must be called using the class name, because they are all ____.
Select one:
a. static methods
b. objects
c. predefined
d. private methods
Question 13
The ToString() method is automatically invoked when an object reference is made in the ____.
Select one:
a. class constructor
b. Write() method
c. mutator method
d. object class
Question 14
To add full functionality to your classes, ____.
Select one:
a. write more than one constructor
b. write a default constructor
c. write at least five constructors for each class
d. omit writing a constructor so that the default one will be created for you
Question 15
To define a property to change a data member of a class include a ____ clause.
Select one:
a. mutator
b. get
c. set
d. value
Question 16
To program an object-oriented solution begin by determining what ____ are needed in the solution.
Select one:
a. data
b. objects
c. processes
d. methods
Question 17
Variables declared in the Main() method are ____.
Select one:
a. visible inside any method in the class.
b. are automatically initilized to zero.
c. must be defined as private data members.
d. only visible inside Main().
Question 18
Answer saved
When you assign a default value to a parameter, it then becomes a(an): ____.
Select one:
a. named parameter
b. static parameter
c. method parameter
d. optional parameter
Question 19
Which method returns the largest whole number less than or equal to the specified number?
Select one:
a. Max()
b. Ceiling()
c. Floor()
d. Largest()
Question 20
Which of the following is NOT a parameter type?
Select one:
a. out
b. in
c. ref
d. params
Question 21
Which of the following is NOT a true statement relating to constructors?
Select one:
a. To add full functionality to your classes, write multiple constructors
b. If you write one constructor, you lose the default one that is created automatically.
c. The default constructor must be the first one written for the class.
d. Constructors are used to provide values to the object's data members.
Question 22
____ are special methods used to read the current state or value of an object member's data.
Select one:
a. accessor
b. mutator
c. constructor
d. setter
Explanation / Answer
Solution 1:
A method must be declared with its return type void, if it will not return any value. If program is using the keyword void, then, it must return any value of the specified return type.
Thus, the correct option is c. must be defined to have a void return type.
Solution 2:
A property is like data field but it does not represent any memory location like data fields. They are used to change the values of some attributes. Thus, they work as methods.
Thus, the correct option is a. data field, method.
Solution 3:
CalculateGrade(90, 75, 83) is a method call in which 3 three arguments have been passed. The function use the parameters and return the value to Console.WriteLine methods, which prints the returned value.
Thus, the correct option is a. a method call.
Solution 4:
Constructors are used to instantiate the class even before invoking the objects. Default constructors are also defined with a keyword public even if any constructor is not defined in the program.
Thus, the correct option is a. public.
Solution 5:
If constructors are not defined in program, then default constructor is invoked. Thus, option a. is correct. A program may contain as many constructors, they are called on the basis of the parameter type. This is called overloading. Thus, option b. is also correct. Constructors just instantiate the class. in constructors, variables are initialized. They do not have any return type. Thus, option c is also correct.
Thus, the correct option is d. all of the above.
Solution 6:
To override a ToString() method, access specifier, then keyword override, then return type string, is used as follows:
public override string ToString()
Thus, the correct option is c. use the keyword override in the heading.
Solution 7:
Testing a class means calling the class methods and apply all test cases on that class by assigning and retrieving the values to and from the variables and checking if that class is working or not. The class should be independent from the driver class.
Thus, the correct option is d. all of the above.
Solution 8:
The methods which cannot be called without objects are called instance methods. Only static methods can be called without objects.
Thus, the correct option is a. non-static method.
Solution 9:
Access modifiers tells that the method is public to all or private to class only. In C#, 4 modifiers are there: public, private, protected, and internal.
Thus, the correct option is a. public.
Solution 10:
The definition of a method tells the function a method is created for. The functioning is written inside the curly braces.
Thus, the correct option is c. includes every thing inside the curly braces.
Solution 11:
First line of a method is signature of the method. Declaration does not contain curly braces and definition of method. When method is defined, it is signature of the method that is followed by its body.
Thus, the correct option is a. signature.
Solution 12:
The method that do not need objects but directly called using class name are knows as static methods. Round(), Max(), etc are called by class name, as they are static methods.
Thus, the correct option is a. static method.
Solution 13:
The method ToString() is directly invoked with method Console.Write(), however it can also be overridden to return the string of current object.
Solution 14:
Only default constructor cannot handle full functionality of the class. Thus, more than one constructor is used.
Thus, the correct option is a. write more than one constructor.
Solution 15:
To change the data member of a class, set clause is used.
Thus, the correct option is c. set.
Solution 16:
In object-oriented programming, the objects are identified first, then the classes are written for each class.
Thus, the correct option is b. objects.
Solution 17:
The variables declared inside main() are local to main() and out of scope for other methods since main() is also a special kind of method.
Thus, the correct option is d.
Solution 18:
After assigning the default value to a parameter, it is not compulsory to include it inside the method call. It becomes optional to include it.
Thus, the correct option is d. optional parameter.
Solution 19:
From a decimal number, if the largest whole number but less than or equal to the given number is required, then floor function is used. Ceiling function returns a number equal to or greater than the specified number.
Thus, the correct option is c. Floor()
Solution 20:
In C#, different types of parameters are there: Named, Ref, Out, Default or optional, dynamic, Value, Params. In is not a parameter type.
Thus, the correct option is b. in.
Solution 21:
Only default constructor cannot handle full functionality of the class. Thus, more than one constructor is used.
Thus, the correct option is a. To add full functionality to your classes, write multiple constructors.
Solution 22:
The methods which are used to get the value or current state of an object member’s data, are known as accessor.
The correct option is a. accessor.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.