Test Series - cpp

Test Number 32/102

Q: What does the data type defined by union will do?
A. It allow one different portion of memory to be accessed as same data types
B. It allow one same portion of memory to be accessed as same data types
C. It allow one different portion of memory to be accessed as different data types
D. It allow one same portion of memory to be accessed as different data types
Solution: Union is used to define the data types of our choice and it will store the data type in one location make them accessible.
Q: What is the syntax of user-defined data types?
A. typedef ExistingDataType NameByUser
B. typedef NameByUser ExistingDataType
C. def NameByUser ExistingDataType
D. def NameByUser ExistingData
Solution: correct syntax is typedef ExistingDataType NameByUser.
typedef int INT; (typedef existing-datatype New-name;).
Q: How many types of user-defined data type are in c++?
A. 1
B. 2
C. 3
D. 4
Solution: There are three types of user-defined data types. They are typedef, union, enumerator.
Q: What is the scope of typedef defined data types?
A. inside that block only
B. whole program
C. outside the program
D. main function
Solution: We are defining the user-defined data type to be availed only inside that program, if we want to use anywhere means we have to define those types in the header file.
Q: How many types of models are available to create the user-defined data type?
A. 1
B. 2
C. 3
D. 4
Solution: There are two types of models. They are references to built-in types and multipart types.
Q: Where does the object is created?
A. class
B. constructor
C. destructor
D. attributes
Solution: In class, only all the listed items except class will be declared.
Q: How to access the object in the class?
A. scope resolution operator
B. ternary operator
C. direct member access operator
D. resolution operator
Solution: Objects in the method can be accessed using direct member access operator which is (.).
Q: Which of these following members are not accessed by using direct member access operator?
A. public
B. private
C. protected
D. both private & protected
Solution: Because of the access is given to the private and protected, We can’t access them by using direct member access operator.
Q: Pick out the other definition of objects.
A. member of the class
B. associate of the class
C. attribute of the class
D. instance of the class
Solution: An Object represents an instance of a class i.e. a variable of that class type having access to its data members and member functions from outside if allowed.
Q: How many objects can present in a single class?
A. 1
B. 2
C. 3
D. as many as possible
Solution: Because a class may contain any number of objects according to its compliance.

You Have Score    /10