Mansoura University: Faculty of Computer Science Class Concepts
10 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the relationship between a type and its instances?

  • A type can only have a single instance associated with it.
  • A type is an abstraction and instances are concrete entities created from that type. (correct)
  • A type is a concrete entity and instances are abstractions of that type.
  • A type and its instances are completely unrelated concepts.
  • What is the difference between an attribute and a behavior of an instance?

  • Attributes are the data members of a class, while behaviors are the member functions.
  • Attributes are characteristics of an instance, while behaviors are the operations the instance can perform. (correct)
  • Attributes are static properties of a class, while behaviors are dynamic properties.
  • Attributes and behaviors are the same thing, just different names for the same concept.
  • What is the relationship between a class and an object?

  • A class is a collection of objects, while an object is a single instance of a class.
  • A class is a type and an object is an instance of that type. (correct)
  • A class is a concrete entity and an object is an abstraction of that class.
  • A class and an object are completely unrelated concepts.
  • What is the purpose of a data member in a class?

    <p>To represent an attribute of an instance of the class.</p> Signup and view all the answers

    Which of the following statements about types and instances is true?

    <p>Many instances can be created from a single type.</p> Signup and view all the answers

    What is the purpose of a member function in a C++ class?

    <p>To represent an operation that can be performed on the objects of the class</p> Signup and view all the answers

    How many sections are needed to write an object-oriented program in C++?

    <p>3</p> Signup and view all the answers

    What is the purpose of the const keyword in the member function declarations getRadius() and getArea()?

    <p>To prevent the member functions from modifying the object's data members</p> Signup and view all the answers

    What is the purpose of the using namespace std; line in the code?

    <p>To include the C++ standard library</p> Signup and view all the answers

    What is the purpose of the double PI = 3.14; line in the getArea() and getPerimeter() member function definitions?

    <p>To define a local variable for the value of pi</p> Signup and view all the answers

    More Like This

    Use Quizgecko on...
    Browser
    Browser