ISDS 505 Final Ch 9 question and answers graded A+
An object is a(n) ________________________ of a class. a. instantiation b. institution c. child d. relative - Answer- a. instantiation A class header or class definition can contain all of the following except ________________________. a. an optional access modifier b. the keyword class c. an identifier d. initial field values - Answer- d. initial field values Most fields in a class are created with the ________________________ modifier. a. public b. private c. new d. protected - Answer- b. private Most methods in a class are created with the ________________________ modifier. a. public b. private c. new d. protected - Answer- a. public Instance methods that belong to individual objects are ________________________ static methods. a. always b. usually c. occasionally d. never - Answer- d. never To allocate memory for an object instantiation, you must use the ________________________ operator. a. mem b. alloc c. instant d. new - Answer- d. new Assume that you have created a class named MyClass. The header of the MyClass constructor can be ________________________. a. public void MyClass() b. public MyClassConstructor() c. Either of these can be the constructor header. d. Neither of these can be the constructor header. - Answer- d. Neither of these can be the constructor header. Assume that you have created a class named MyClass. The header of the MyClass constructor can be ________________________. a. public MyClass() b. public MyClass(double d) c. Either of these can be the constructor header. d. Neither of these can be the constructor header. - Answer- c. Either of these can be the constructor header. Assume that you have created a class named DemoCar. Within the Main() method of this class, you instantiate a Car object named myCar and the following statement executes correctly: WriteLine("The Car gets {0} miles per gallon", myCar.ComputeMpg()); Within the Car class, the ComputeMpg() method can be ________________________. a. public and static b. public and nonstatic c. private and static d. private and nonstatic - Answer- b. public and nonstatic
Información del documento
- Subido en
- 18 de marzo de 2024
- Número de páginas
- 6
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas