1.
A ________ is a user defined data type.
Correct Answer
A. Abstract data type
Explanation
An abstract data type is a user-defined data type that defines a set of data values and the operations that can be performed on those values. It encapsulates the data and provides a set of methods or functions to manipulate that data. Unlike primitive data types like variables or pointers, abstract data types are not built-in and are defined by the user based on their specific requirements. They allow for the creation of complex data structures and provide a higher level of abstraction for organizing and manipulating data.
2.
Each data type consists of both a type and ________ for the type.
Correct Answer
B. Operational capabilities
Explanation
Each data type not only has a specific type but also possesses operational capabilities that define what actions can be performed on the data of that type. These operational capabilities include various methods and functions that can be applied to the data, allowing for specific operations to be carried out. Therefore, the operational capabilities complement and complete the definition of a data type.
3.
A ________ is defined as the combination of data and the operations that can be performed on the data.
Correct Answer
C. Data type
Explanation
A data type is defined as the combination of data and the operations that can be performed on the data. It specifies the type of data that can be stored in a variable and the operations that can be performed on that data. This allows for efficient storage and manipulation of data in a program.
4.
A ________ is an abstract data type that defines both data and functions.
Correct Answer
A. Class
Explanation
A class is an abstract data type that defines both data and functions. It is a blueprint or template for creating objects, which are instances of the class. Classes encapsulate data and behavior into a single unit, allowing for code reusability and organization. The data in a class is represented by variables, known as attributes or properties, and the functions are known as methods. By defining a class, we can create multiple objects with the same structure and behavior, making it an essential concept in object-oriented programming.
5.
A ________ is a function contained in a class.
Correct Answer
D. Method
Explanation
A method is a function contained within a class. It is used to define the behavior or actions that an object of the class can perform. Methods are associated with a specific class and can access and manipulate the data members and attributes of that class. They are essential for encapsulating functionality within an object-oriented programming paradigm.
6.
Object oriented programming: (I) supports code reusability, (II) is an exclusive feature of C++, and (III) contribute to productivity in software development.
Correct Answer
B. Only I and III are correct.
Explanation
Object-oriented programming (OOP) supports code reusability by allowing the creation of classes and objects that can be reused in different parts of a program. This promotes modular and efficient coding practices. Additionally, OOP contributes to productivity in software development by providing concepts such as encapsulation, inheritance, and polymorphism, which help in organizing and managing complex codebases. However, OOP is not an exclusive feature of C++. It is a programming paradigm that is supported by various programming languages like Java, Python, and Ruby.
7.
A class member is a data member. This statement is:
Correct Answer
B. Sometimes true.
Explanation
The statement "A class member is a data member" is sometimes true. In object-oriented programming, a class member can refer to both data members and member functions. Data members are variables that hold data within a class, while member functions are methods that perform operations on the data. Therefore, in some cases, a class member can indeed be a data member. However, it is important to note that not all class members are necessarily data members, as they can also include member functions.
8.
A data member is a member function. This statement is:
Correct Answer
C. Never true.
Explanation
This statement is never true because a data member and a member function are two different things in programming. A data member is a variable that holds data within a class or object, while a member function is a function that operates on the data members of a class. They serve different purposes and cannot be used interchangeably, so the statement is incorrect.
9.
Data members are also called ________.
Correct Answer
C. Instance variables
Explanation
Data members in object-oriented programming are variables that are associated with a specific instance of a class. They hold the state or data of an object and are also known as instance variables. These variables are unique to each object and can have different values for each instance. Therefore, the correct answer is "instance variables".
10.
Class names ________ start with a capital letter.
Correct Answer
A. May
Explanation
Class names may start with a capital letter. This means that it is not mandatory for class names to start with a capital letter, but it is allowed. It is a common convention in many programming languages to start class names with a capital letter, but it is not a strict rule.
11.
________ define the access rights to variables and functions in a class.
Correct Answer
D. Access specifiers
Explanation
Access specifiers in a class define the access rights to variables and functions. They determine whether these members can be accessed from within the class itself, from derived classes, or from outside the class. By using access specifiers, such as public, private, or protected, developers can control the visibility and accessibility of class members, ensuring proper encapsulation and data hiding.
12.
The private members of a class can be accessed by any function all throughout that particular class.
Correct Answer
A. True
Explanation
The statement is true because in object-oriented programming, private members of a class can only be accessed by other members of the same class. This means that any function within the class can access and manipulate the private members. Outside of the class, however, private members are not accessible. Therefore, any function within the class can indeed access the private members throughout the entire class.
13.
The public members of a class can be accessed by any function all throughout that particular class.
Correct Answer
A. True
Explanation
The statement is true because public members of a class are accessible by any function within that class. This means that any function, regardless of its location within the class, can access and use the public members of the class without any restrictions.
14.
A ________ is a function used to initialize class members with values.
Correct Answer
D. Constructor
Explanation
A constructor is a function used to initialize class members with values. Constructors are special member functions that are automatically called when an object of a class is created. They are used to set initial values to the data members of the class and perform any necessary setup operations. Constructors have the same name as the class and do not have a return type. They are essential in object-oriented programming to ensure that objects are properly initialized before they are used.
15.
If for example, there is a class named Person. Then, an appropriate constructor header of that class would be:
Correct Answer
A. Person::Person( )
Explanation
The appropriate constructor header for the class named Person would be "Person::Person( )". This is because the constructor name should match the class name, and it should not have a return type specified, not even void. Therefore, "Person::Person( )" is the correct constructor header for the Person class.
16.
A class may have more than one constructor.
Correct Answer
A. True
Explanation
This statement is true because in object-oriented programming, a class can have multiple constructors. Constructors are special methods that are used to initialize objects of a class. Having multiple constructors allows for different ways of creating objects with different sets of initial values or parameters. This provides flexibility and allows the programmer to choose the appropriate constructor based on the requirements of the object being created.
17.
A class may have more than one default constructor.
Correct Answer
B. False
Explanation
A class cannot have more than one default constructor. A default constructor is a constructor that is automatically generated by the compiler if no constructor is defined in the class. It initializes the object with default values. If more than one default constructor is allowed, it would create ambiguity and confusion as to which constructor should be used. Therefore, the statement is false.
18.
You can create one or more objects from a class.
Correct Answer
A. True
Explanation
This statement is true because in object-oriented programming, you can create multiple instances of a class, each representing a unique object with its own set of properties and behaviors. Objects are created using the class as a blueprint, allowing you to create and manipulate multiple objects with similar characteristics and functionalities. Therefore, it is possible to create one or more objects from a class.
19.
You can create one or more classes out of a single object.
Correct Answer
B. False
Explanation
The statement "You can create one or more classes out of a single object" is false. In object-oriented programming, classes are used to define objects and their behavior. Each class represents a blueprint for creating multiple objects of the same type. Therefore, a single object cannot be used to create multiple classes.