Chapter 12
40 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 a class that inherits called?

  • Polymorphic class
  • Superclass
  • Derived class (correct)
  • Abstract data type
  • What is the central theme in object-oriented programming and languages that support it?

  • Polymorphism
  • Inheritance (correct)
  • Abstraction
  • Encapsulation
  • What are subprograms that define operations on objects called?

  • Methods (correct)
  • Functions
  • Procedures
  • Routines
  • What allows new classes to be defined in terms of existing ones in object-oriented programming?

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

    What is a characteristic of a nested class in Java?

    <p>It is hidden from all classes in its package, except for the nesting class</p> Signup and view all the answers

    What is true about dynamic binding in Java?

    <p>It is the normal way to bind method calls to method definitions</p> Signup and view all the answers

    What is a storage structure for instance variables in Java?

    <p>Class instance records (CIRs)</p> Signup and view all the answers

    What is the purpose of reflection in a programming language?

    <p>Allows programs to have runtime access to their types and structure</p> Signup and view all the answers

    What does the getClass method of Class return in Java?

    <p>The Class object of an object</p> Signup and view all the answers

    What does the Method class's invoke method do in Java?

    <p>Executes the method found by getMethod</p> Signup and view all the answers

    What is a downside of reflection in Java?

    <p>Performance costs</p> Signup and view all the answers

    What are the major design issues involved in object-oriented programming (OOP)?

    <p>Exclusivity of objects, subclasses and subtypes, type checking and polymorphism</p> Signup and view all the answers

    What is a characteristic of Java as a programming language?

    <p>It supports only OOP</p> Signup and view all the answers

    What is a use case of reflection in software tools?

    <p>Class browsers need to enumerate the classes of a program</p> Signup and view all the answers

    What does the getMethods method of Class return in Java?

    <p>An array of all public methods of a class</p> Signup and view all the answers

    What is a limitation of reflection in Java?

    <p>Some reflection code may not run under a security manager, making code nonportable</p> Signup and view all the answers

    What is the entire collection of methods of an object called?

    <p>Message protocol</p> Signup and view all the answers

    How can a class modify an inherited method?

    <p>By overriding the inherited method</p> Signup and view all the answers

    What are the two kinds of variables in a class?

    <p>Class variables and instance variables</p> Signup and view all the answers

    What does dynamic binding allow?

    <p>Polymorphic variables to reference objects of the class and its descendants</p> Signup and view all the answers

    What does an abstract class include?

    <p>At least one abstract method and cannot be instantiated</p> Signup and view all the answers

    What are the design issues for OOP languages?

    <p>Exclusivity of objects, single and multiple inheritance, object allocation and deallocation, dynamic and static binding, nested classes, and initialization of objects</p> Signup and view all the answers

    What is the relationship of subclasses to their parent class?

    <p>&quot;is-a&quot; relationship</p> Signup and view all the answers

    What is a disadvantage of Multiple Inheritance?

    <p>Creating interdependencies among classes that complicate maintenance</p> Signup and view all the answers

    Where can object allocation and deallocation occur?

    <p>Anywhere if objects behave like ADTs and can be explicitly created on the heap</p> Signup and view all the answers

    What should be considered for efficiency?

    <p>Dynamic and static binding</p> Signup and view all the answers

    What does an abstract method not include?

    <p>A definition</p> Signup and view all the answers

    What can multiple inheritance allow a new class to inherit from?

    <p>Two or more classes</p> Signup and view all the answers

    Which language supports multiple inheritance and dynamic binding through virtual methods and pure virtual functions?

    <p>C++</p> Signup and view all the answers

    Which language has a category that provides some benefits of multiple inheritance through interfaces?

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

    Which language allows reexportation to make a member visible in a subclass, even if it was originally inaccessible due to private derivation?

    <p>C++</p> Signup and view all the answers

    Which language explicitly calls the finalize method when the garbage collector is about to reclaim the storage occupied by the object?

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

    Which language requires the programmer to decide at design time which methods will be statically bound and which must be dynamically bound?

    <p>C++</p> Signup and view all the answers

    Which language has wrapper classes for primitive types and allocates objects heap-dynamically with new?

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

    Which language supports single inheritance and dynamic binding for all messages unless the method is final or static?

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

    Which language provides elaborate access controls to class entities such as private, public, and protected?

    <p>C++</p> Signup and view all the answers

    Which language has a mixed typing system, constructors, destructors, and elaborate access controls to class entities?

    <p>C++</p> Signup and view all the answers

    Which language allows subclassing to be declared with access controls such as private or public, defining potential changes in access by subclasses?

    <p>C++</p> Signup and view all the answers

    Which language disallows overriding and allows static binding for methods that are final or static?

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

    Which language has differences in support of OOP, with extensive access controls, multiple inheritance, and dynamic binding?

    <p>C++</p> Signup and view all the answers

    Study Notes

    OOP Support in C++ and Java

    • C++ is an OOP language evolved from C and SIMULA 67, featuring mixed typing system, constructors, destructors, and elaborate access controls to class entities.
    • In C++, inheritance is supported, and access controls for members include private, public, and protected.
    • Subclassing in C++ can be declared with access controls such as private or public, defining potential changes in access by subclasses.
    • In C++, reexportation allows making a member visible in a subclass, even if it was originally inaccessible due to private derivation.
    • C++ supports multiple inheritance and dynamic binding through virtual methods and pure virtual functions.
    • Dynamic binding in C++ allows calling methods through polymorphic variables and binding to messages.
    • C++ provides extensive access controls, multiple inheritance, and requires the programmer to decide at design time which methods will be statically bound and which must be dynamically bound.
    • Java, closely related to C++, has all data as objects except primitive types, with wrapper classes for primitive types, and objects are heap-dynamic and allocated with new.
    • In Java, single inheritance is supported and an abstract class category provides some benefits of multiple inheritance through interfaces.
    • All messages in Java are dynamically bound to methods unless the method is final or static, which disallows overriding and allows static binding.
    • Java's finalize method is implicitly called when the garbage collector is about to reclaim the storage occupied by the object.
    • Overall, C++ and Java have differences in support of OOP, with C++ providing extensive access controls, multiple inheritance, and dynamic binding, while Java supports single inheritance and dynamic binding for all messages.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    CSI3120A_Fall2023_Lecture11.pdf

    More Like This

    Use Quizgecko on...
    Browser
    Browser