Chapter 12

HilariousSagacity avatar
HilariousSagacity
·
·
Download

Start Quiz

Study Flashcards

40 Questions

What is a class that inherits called?

Derived class

What is the central theme in object-oriented programming and languages that support it?

Inheritance

What are subprograms that define operations on objects called?

Methods

What allows new classes to be defined in terms of existing ones in object-oriented programming?

Inheritance

What is a characteristic of a nested class in Java?

It is hidden from all classes in its package, except for the nesting class

What is true about dynamic binding in Java?

It is the normal way to bind method calls to method definitions

What is a storage structure for instance variables in Java?

Class instance records (CIRs)

What is the purpose of reflection in a programming language?

Allows programs to have runtime access to their types and structure

What does the getClass method of Class return in Java?

The Class object of an object

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

Executes the method found by getMethod

What is a downside of reflection in Java?

Performance costs

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

Exclusivity of objects, subclasses and subtypes, type checking and polymorphism

What is a characteristic of Java as a programming language?

It supports only OOP

What is a use case of reflection in software tools?

Class browsers need to enumerate the classes of a program

What does the getMethods method of Class return in Java?

An array of all public methods of a class

What is a limitation of reflection in Java?

Some reflection code may not run under a security manager, making code nonportable

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

Message protocol

How can a class modify an inherited method?

By overriding the inherited method

What are the two kinds of variables in a class?

Class variables and instance variables

What does dynamic binding allow?

Polymorphic variables to reference objects of the class and its descendants

What does an abstract class include?

At least one abstract method and cannot be instantiated

What are the design issues for OOP languages?

Exclusivity of objects, single and multiple inheritance, object allocation and deallocation, dynamic and static binding, nested classes, and initialization of objects

What is the relationship of subclasses to their parent class?

"is-a" relationship

What is a disadvantage of Multiple Inheritance?

Creating interdependencies among classes that complicate maintenance

Where can object allocation and deallocation occur?

Anywhere if objects behave like ADTs and can be explicitly created on the heap

What should be considered for efficiency?

Dynamic and static binding

What does an abstract method not include?

A definition

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

Two or more classes

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

C++

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

Java

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

C++

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

Java

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

C++

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

Java

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

Java

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

C++

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

C++

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

C++

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

Java

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

C++

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.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Chapter 12
10 questions

Chapter 12

DelectableChalcedony avatar
DelectableChalcedony
Chapter 12 Quiz
4 questions

Chapter 12 Quiz

SupportingPorcupine avatar
SupportingPorcupine
Chapter 12 Mobile Marketing Questions
38 questions
chapter 12,13,14 easy questions
44 questions
Use Quizgecko on...
Browser
Browser