Test Series - oops

Test Number 30/78

Q: A factory object is used ______________________
A. To create new classes
B. To create new function
C. To create new data members
D. To create new objects
Solution: The factory object is an object that can be used to create other objects. If it is seen formally, it behaves like a method that will return object on its use. The object returned is assumed to be a new object.
Q: What are singleton objects?
A. The only two objects of a class throughout the program
B. The only object of a class throughout the program
C. The objects that are alive throughout the program
D. The objects that are created and then deleted without use
Solution: If a class has only one object created and that is the only object of the class. Then the object is known as the singleton object. But only if that object is the only object of the class and no other object is created for that class.
Q: Object cout and cin _________________
A. Can be used directly with << and >> symbols respectively
B. Can be used directly with >> and << symbols respectively
C. Must be used as a function which accepts 2 arguments
D. Must be used as a function which accepts 3 arguments
Solution: The cin and cout objects can be used directly with the >> and << operators respectively. The objects are of iostream class. Class iostream is an inbuilt class.
Q: Objects type ____________________
A. Can be changed in runtime
B. Can’t be changed in runtime
C. Can be changed in compile time
D. May or may not get changed
Solution: The object types are always fixed. Once the object is created of a specific type then it can’t be changed. Neither at runtime nor at compile time.
Q: An object can be used to represent _________________
A. A real world entity
B. A real function
C. Some real data only
D. Some function only
Solution: The objects are actually meant to represent an entity. The classes are real world object’s blueprint. The classes then are used to create an entity representation.
Q: Objects can be used _____________________
A. To access any member of a class
B. To access only public members of a class
C. To access only protected members of a class
D. To access only private members of a class
Solution: The objects are created for a specific class. Then the objects can be used to access the public members of a class. The members can be the data members or the member functions of the class.
Q: Which among the following is not a use of object?
A. Defining a member function
B. Accessing data members
C. Creating instance of a class
D. Using class members
Solution: The objects can’t be used to define any member function. Member functions must be defined by the class only. Objects can only access the members and use them.
Q: Which object can be used to access the standard input?
A. System.inner
B. cin
C. System.stdin
D. console.input
Solution: Object cin can be used to take input from the standard input. It is used in C++. In java we can use System.in for the standard input stream. The syntax changes from language to language.
Q: A single object can be used __________________
A. As only two class types at a time
B. As only three class types at a time
C. As only one class type at a time
D. As of as many class types as required
Solution: The object can be of only one type. The type of an object can’t be changed. Object type is mandatory to be of one class type to ensure the type and number of data members it have.
Q: If same object name is given to different objects of different class then _____________
A. Its compile time error
B. Its runtime error
C. It’s not an error
D. Program suns smooth
Solution: It is a compile time error as the compiler doesn’t allow the same name objects to be declared more than once. Compiler produces multiple declaration errors. Every object must have a different name.

You Have Score    /10