Chapter 3 Flashcards

1
Q
  1. 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. True or false: Double and float data types can store values with decimals.
A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. 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();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. True or false: structs can contain methods.
A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. 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;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. What are two methods with the same name but with different parameters?
    a. Overloading
    b. Overriding
    c. Duplexing
    d. Duplicate
A

a. Overloading

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

E1. You want to create a type in your code that stores multiple values of differing types but don’t need the full facilities of a class file. What is the value type that can serve your needs?

a. Array
b. Struct
c. Queue
d. Linked List

A

b. Struct

17
Q

E2. You can change the increment of Enumerations. True or false?

A

False

18
Q

E3. Overloading a method can be accomplished by changing only the order of the parameters. True or false?

A

False

19
Q

E4. Optional parameters in a method must exist where in the parameter list?

a. At the beginning
b. At the end
c. After any default parameters
d. Anywhere

A

b. At the end

20
Q

E5. What modifier is used on the properties of a class?

a. Private
b. Static
c. Public
d. Property

A

c. Public