Test Series - oops

Test Number 29/78

Q: The objects in an object array _______________________
A. Can be created without use of constructor
B. Can be created without calling default constructor
C. Can’t be created with use of constructor
D. Can’t be created without calling default constructor
Solution: The objects need some constructor to get the memory spaced reserved for those. If the default constructor is not used then we can use some arguments constructor which will reserve the memory for the objects. The objects can be passed with constructor arguments during declaration.
Q: The Object array is created in _____________________
A. Heap memory
B. Stack memory
C. HDD
D. ROM
Solution: If the object arrays are declared dynamically, then the memory will be reserved on heap. The memory for objects will be on stack only if some constructor or some call and return tasks are happening. The program doesn’t run on HDD and ROM is not used for the execution of programs.
Q: If an array of objects is of size 10 and a data value have to be retrieved from 5th object then ________________ syntax should be used.
A. Array_Name[4].data_variable_name;
B. Data_Type Array_Name[4].data_variable_name;
C. Array_Name[4].data_variable_name.value;
D. Array_Name[4].data_variable_name(value);
Solution: The array name with the index of fifth element is called, i.e. index 4. Then the dot operator is used to access the data member of that object. This Allows us to access the data members of all the objects in an object array.
Q: Can we have two dimensional object array?
A. Yes, always
B. Yes, only if primitive type array
C. No, since two indices are impossible
D. No, never
Solution: A two dimensional array can always be created. There is no rule that only primitive type objects can have more than one dimension. The object array can also be made 2 dimensional.
Q: Is an array of characters always a string?
A. Yes, always
B. Yes, if each character is terminated by null
C. No, since each character is terminated by null
D. No, never
Solution: The character arrays are not the same as string. The string once created then remains the same. The character array values may change.
Q: Which among the following is the main use of object?
A. To create instance of a function
B. To create instance of a program
C. To create instance of class
D. To create instance of structures
Solution: The objects are used to create an instance of a class. Objects can represent a class in an independent form. The basic blueprint, that contains the information of the type of data that can be stored in an object, is given by the class.
Q: Which among the following is not a property of an object?
A. Identity
B. Properties
C. Attributes
D. Names
Solution: The names are not property of an object. The identity can be in any form like address or name of object but name can’t be termed as only identity of an object. The objects contain attributes that define what type of data an object can store.
Q: What is function object?
A. An object with a single function
B. An object with only functions
C. An object with more than one function
D. An object with no functions
Solution: A function object is an object with single function. In C++ a function object can be like operator() function. This acts more like a function rather than an object.
Q: Immutable object are used ______________________
A. To set up as a fixed state
B. To set up variable object
C. To set up an object of abstract class
D. To set up an object of derived class
Solution: An immutable object can be created for an object which has to be fixed with values. The object data will not be changed throughout the program. This can be useful to eliminate the unintentional changes in the data of object.
Q: Which object can be used to contain other objects?
A. First class object
B. Derived class object
C. Container object
D. Enclosure object
Solution: A container object can be used to contain other objects. Container object is an ADT. Its object are collection of other objects. Some specific rules apply to these types of objects.

You Have Score    /10