Test Series - oops

Test Number 36/78

Q: Which among the following is the main characteristic of class?
A. Inheritance
B. Encapsulation
C. Polymorphism
D. Object creation
Solution: The classes are made to encapsulate the data and properties that are most similar and can be grouped together inside a single class. This single class can represent all of those features by creating its instances.
Q: To group all the brands of cars, what should be used?
A. Class
B. Structure
C. Function
D. Object
Solution: A class can be used to group all the brands of cars. The Different brands may have different properties but all will have some common properties like number of wheels and doors, accessories etc. All of those properties can be grouped into a single class representing all the cars.
Q: If a class have two data members and two functions to add those two numbers and to subtract them, which among the following is most efficient if the programmer wants to implement multiplication too?
A. Define a public function which multiplies two numbers
B. Define a public function that returns values of two data members
C. Define a private function which multiplies two numbers
D. Define a private function that returns values of two data members
Solution: The best choice would be to define a public member function that returns the values of two data members of the class. This way we can implement any operation on those data members. Also there won’t be any need to modify the program and to add new functions for each new operation.
Q: If a database have to be maintained using OOP, to store the details of each employee in a company, which would be the best choice among the following?
A. Define a class to store details of each employee
B. Define a structure to store details of each employee
C. Define separate variable for each detail
D. Define a generic type to store string and number details
Solution: A single class can be defined that represents a single employee of a company. The specific type of functions that can be applied to specific employees can be put into another class that is derived from the existing class.
Q: Which class represents the most abstracted information?
A. Nested
B. Derived
C. Enclosed
D. Base
Solution: The base classes are the most abstracted part of information. A base class having many other derived classes would have a bigger overview of all the other derived classes. Hence the base classes have the most abstract information.
Q: Which among the following is an advantage of using classes over structures of C?
A. Functions are restricted
B. Functions can’t be defined
C. Functions can also be encapsulated
D. Functions can have more security
Solution: The functions are also made easy to be encapsulated inside a class. In structures, only the data members were allowed to be encapsulated. Hence classes can represent an entity in a better way.
Q: Which among the following is a feature of class?
A. Object orientation
B. Procedure orientation
C. Both object and procedure orientation
D. Neither object nor procedure orientation
Solution: Thee use of classes feature the object oriented programming. The OOP concept can be implemented by using class and their objects. Procedures orientation is not a feature of OOP.
Q: Class is _____________ of an object.
A. Basic function definition
B. Detailed description with values
C. Blueprint
D. Set of constant values
Solution: The class is an overview for an object. It contains the basic details map of data that an object will contain. An object is independent representation of class.
Q: In which case the classes can be used to make the more efficient program?
A. To define a function that is called frequently in a program
B. To structure data that is most similar
C. To group the most similar data and operations
D. To define a blueprint that shows memory location of data
Solution: The classes would be more suitable to use in case where we need to group the most similar data and operations. The data can be represented as data members of class and operations as member functions of class. This is indirectly encapsulation feature.
Q: What is the use of inbuilt classes?
A. Provide predefined data
B. Provide predefined functions
C. Provide predefined data and functions
D. Provide predeclared data to be overridden
Solution: The data that is constant or is always the same initially for use can be provided by some inbuilt classes. The functions that are mostly used are also provided by the inbuilt classes. The data and functions can be used by including the corresponding header file or library.

You Have Score    /10