Chapter 3 Flashcards
1
Q
- What is the maximum value you can store in an int data type?
a. Positive infinity
b. 32,167
c. 65,536
d. 4,294,967,296
A
d. 4,294,967,296
2
Q
- True or false: Double and float data types can store values with decimals.
A
True
3
Q
- Which declaration can assign the default value to an int type?
a. new int();
b. int myInt = new int();
c. int myInt;
d. int myInt = new int(default);
A
b. int myInt = new int();
4
Q
- True or false: structs can contain methods.
A
True
5
Q
- What is the correct way to access the firstName property of a struct named Student?
a. string name = Student.firstName;
b. string name = Student.firstName();
c. string name = Student(firstName);
d. string name = Student.(firstName);
A
a. string name = Student.firstName;
6
Q
- In the following enumeration, what will be the underlying value of Wed?
enum Days {Mon = 1, Tue, Wed, Thur, Fri, Sat, Sun};
a. 2
b. 3
c. 4
d. It has no numeric value.
A
b. 3
7
Q
- What are two methods with the same name but with different parameters?
a. Overloading
b. Overriding
c. Duplexing
d. Duplicate
A
a. Overloading
8
Q
- What is the parameter in this method known as?
public void displayAbsoluteValue(int value = 1)
a. Modified
b. Optional
c. Named
d. Default
A
b. Optional
9
Q
- When you create an abstract method, how do you use that method in a derived class?
a. You must overload the method in your derived class.
b. You must override the method in your derived class.
c. Abstract methods cannot be used in derived classes.
d. You need to declare the method as virtual in your derived class.
A
b. You must override the method in your derived class.
10
Q
- How do you enforce encapsulation on the data members of your class?
a. Create private data members.
b. Create private methods.
c. Use public properties.
d. Use private properties.
e. Use the protected access modifier on methods, properties, and member variables.
A
a. Create private data members.
c. Use public properties.
11
Q
- Boxing refers to:
a. Encapsulation
b. Converting a value type to a reference type
c. Converting a reference type to a value type
d. Creating a class to wrap functionality in a single entity
A
b. Converting a value type to a reference type
12
Q
- What is one advantage of using named parameters?
a. You can pass the arguments in to the method in any order using the parameter names.
b. You can pass in optional arguments as long as you use the parameter names in your arguments.
c. Named parameters make compiling much faster.
d. Name parameters do not affect compile time.
A
a. You can pass the arguments in to the method in any order using the parameter names.
13
Q
- What is an advantage of using generics in .NET?
a. Generics enable you to create classes that span types.
b. Generics enable you to create classes that accept the type at creation time.
c. Generics perform better than nongeneric classes.
d. Generics do not use optional parameters.
A
b. Generics enable you to create classes that accept the type at creation time.
14
Q
- What does the designator indicate in a generic class?
a. It is the parameter for all arguments passed in to the class constructor.
b. It is the parameter designator for the default method of the class.
c. It is a placeholder that will contain the object type used.
d. It is a placeholder that will serve as the class name.
A
c. It is a placeholder that will contain the object type used.
15
Q
- How are the values passed in generic methods?
a. They are passed by value.
b. They are passed by reference.
c. They must be encapsulated in a property.
d. They are passed during class instantiation.
A
b. They are passed by reference.