Cs132 Quiz #4 - Classes

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Msfstamaria
M
Msfstamaria
Community Contributor
Quizzes Created: 1 | Total Attempts: 362
Questions: 19 | Attempts: 362

SettingsSettingsSettings
Cs132 Quiz #4 - Classes - Quiz

CS132 Quiz #4 - Classes


Questions and Answers
  • 1. 

    A ________ is a user defined data type.

    • A.

      Abstract data type

    • B.

      Object

    • C.

      Variable

    • D.

      Pointer

    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.

    Rate this question:

  • 2. 

    Each data type consists of both a type and ________ for the type.

    • A.

      Attributes

    • B.

      Operational capabilities

    • C.

      Structures

    • D.

      Prototypes

    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.

    Rate this question:

  • 3. 

    A ________ is defined as the combination of data and the operations that can be performed on the data.

    • A.

      Specification

    • B.

      Address

    • C.

      Data type

    • D.

      Pointer

    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.

    Rate this question:

  • 4. 

    A ________ is an abstract data type that defines both data and functions.

    • A.

      Class

    • B.

      Object

    • C.

      Prototype

    • D.

      Structure

    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.

    Rate this question:

  • 5. 

    A ________ is a function contained in a class.

    • A.

      Attribute

    • B.

      Class member

    • C.

      Data member

    • D.

      Method

    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.

    Rate this question:

  • 6. 

    Object oriented programming: (I) supports code reusability, (II) is an exclusive feature of C++, and (III) contribute to productivity in software development.

    • A.

      Only I and II are correct.

    • B.

      Only I and III are correct.

    • C.

      Only II and III are correct.

    • D.

      All of them are correct.

    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.

    Rate this question:

  • 7. 

    A class member is a data member. This statement is:

    • A.

      Always true.

    • B.

      Sometimes true.

    • C.

      Never true.

    • D.

      Worthless (just like my instructor in CS132).

    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.

    Rate this question:

  • 8. 

    A data member is a member function. This statement is:

    • A.

      Always true.

    • B.

      Sometimes true.

    • C.

      Never true.

    • D.

      Funny (just like the face of my instructor in CS132).

    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.

    Rate this question:

  • 9. 

    Data members are also called ________.

    • A.

      Methods

    • B.

      Function prototypes

    • C.

      Instance variables

    • D.

      Instance methods

    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".

    Rate this question:

  • 10. 

    Class names ________ start with a capital letter.

    • A.

      May

    • B.

      Should never

    • C.

      Should always

    • D.

      Will cause an error when they

    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.

    Rate this question:

  • 11. 

    ________ define the access rights to variables and functions in a class.

    • A.

      Class members

    • B.

      Function parameters

    • C.

      Overloaders

    • D.

      Access specifiers

    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.

    Rate this question:

  • 12. 

    The private members of a class can be accessed by any function all throughout that particular class.

    • A.

      True

    • B.

      False

    • C.

      Sometimes true

    • D.

      Cannot determine from the given statement

    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.

    Rate this question:

  • 13. 

    The public members of a class can be accessed by any function all throughout that particular class.

    • A.

      True

    • B.

      False

    • C.

      Sometimes false

    • D.

      Cannot determine from the given statement

    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.

    Rate this question:

  • 14. 

    A ________ is a function used to initialize class members with values.

    • A.

      Destructor

    • B.

      Function prototype

    • C.

      Method

    • D.

      Constructor

    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.

    Rate this question:

  • 15. 

    If for example, there is a class named Person. Then, an appropriate constructor header of that class would be:

    • A.

      Person::Person( )

    • B.

      Void Person::Person( )

    • C.

      Person::setPerson( )

    • D.

      Void Person::setPerson( )

    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.

    Rate this question:

  • 16. 

    A class may have more than one constructor.

    • A.

      True

    • B.

      False

    • C.

      Sometimes true

    • D.

      Cannot determine from the given statement

    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.

    Rate this question:

  • 17. 

    A class may have more than one default constructor.

    • A.

      True

    • B.

      False

    • C.

      Sometimes false

    • D.

      Cannot determine from the given statement

    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.

    Rate this question:

  • 18. 

    You can create one or more objects from a class.

    • A.

      True

    • B.

      False

    • C.

      Sometimes true

    • D.

      Cannot determine from the given statement

    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.

    Rate this question:

  • 19. 

    You can create one or more classes out of a single object.

    • A.

      True

    • B.

      False

    • C.

      Sometimes true

    • D.

      Cannot determine from the given statement

    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.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 23, 2009
    Quiz Created by
    Msfstamaria
Back to Top Back to top
Advertisement