Ch 11 & 12

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

In Java 5.0, it supports for ____ types and methods to Java. The name of a(n) ___ class in Java 5.0 is specified by a name followed by one or more type variables delimited by pointed brackets. ad-hoc generic inheritance subtype supertype

generic

Parametrically polymorphic subprograms are often called _____ subprograms. ad-hoc generic inheritance subtype supertype

generic

_____provide the programmer with a method of organizing programs that also facilitates recompilation

Encapsulations

What is a friend function? What is a friend class?

Friend function to allowed access to public, private, or protected data in that class. Friend class can access the "private" and "protected" members of the class in which it is declared as a friend

Why are destructors not as frequently needed in Java as they are in C++?

One obvious difference is the lack of a destructor in the Java version, obviated by Java's implicit garbage collection

_____ is a pure object-oriented language

Smalltalk

How are C++ class instances created?

Stack dynamic instances of classes are always created by the elaboration of an object declaration . Furthermore, the lifetime of such a class instance ends when the end of the scope of its declaration is reached. Heap dynamic class instances are created with the new operator and destroyed with the delete operator.

An _____ is one that includes at least one abstract method . It cannot be instantiated

abstract class

An _____ is one that does not include a definition (it only defines a protocol)

abstract method

A(n) ___ is a view or representation of an entity that includes only the most significant attributes. abstraction polymorphism encapsulation inheritance generic

abstraction

All subprograms are process ____(s) because they provide a way for a program to specify a process, without providing the details of how it performs its task (at least in the calling program). abstraction polymorphism encapsulation inheritance generic

abstraction

An _____ is a view or representation of an entity that includes only the most significant attributes

abstraction

The evolution of data ____ began in 1960 with the first version of COBOL, which included the record data structure. The C-based languages have structs, which are also records. abstraction polymorphism encapsulation inheritance generic

abstraction

Overloaded subprograms provide a particular kind of polymorphism called ___ polymorphism. ad-hoc generic inheritance subtype supertype

ad-hoc

_____ polymorphism is also called explicit parametric polymorphism. ad-hoc generic inheritance subtype supertype

ad-hoc

In Java, if a generic method has two or more restrictions on its generic type, they are added to the extends-clause, separated by _____. comma semicolon ampersand plus star

ampersand

C++ class entities that are hidden from the clients are placed in a _____

private clause

In Java, the expression <T extends BoundingType> specifies that T should be a(n) ____ of the bounding type. ad-hoc generic inheritance subtype supertype

subtype

Languages that support object-oriented programming usually support ____ polymorphism. ad-hoc generic inheritance subtype supertype

subtype

____ polymorphism is fundamental to object-oriented languages, in which classes are said to inherit the methods of their parent classes. ad-hoc generic inheritance subtype supertype

subtype

____ polymorphism means that a variable of type T can access any object of type T or any type derived from T. ad-hoc generic inheritance subtype supertype

subtype

In OOPL, we can encapsulate our subroutine as a method of a simple object, and let the object's fields hold context for the method. An object that plays the role of a function and its referencing environment may variously be called ___. abstract class parametric object polymorphic object standard template object subtype class object closure object template

subtype class

In Java, for generic class<T>, T is the ___ variable. ad-hoc type polymorphic first-class primitive

type

Class instances in C++ can be static, stack dynamic, or heap dynamic . If static or stack dynamic, they are referenced directly with _____. If heap dynamic, they are referenced through _____.

value variables, pointers

Java 5.0 supports ____ types which can be used for any collection type of any class components. bound generic polymorphic wildcard primitive

wildcard

_____supports abstract data types with both classes and structs. Its structs are value types and do not support inheritance

C#

Where are all Java methods defined?

All Java methods are defined in a class .

From where are Java class instances allocated?

All objects are allocated from the heap and accessed through reference variables.

What is a polymorphic variable?

A polymorphic variable can be defined in a class that is able to reference (or point to) objects of the class and objects of any of its descendants. When a class hierarchy includes classes that override methods and such methods are called through a polymorphic variable, the binding to the correct method will be dynamic .

What are the language design requirements for a language that supports abstract data types?

A syntactic unit in which to encapsulate the type definition. A method of making type names and subprogram headers visible to clients, while hiding actual definitions . Some primitive operations must be built into the language processor.

Describe the three characteristic features of object-oriented languages

Abstract data types, Inheritance and Polymorphism

What are the advantages of the two parts of the definition of abstract data type?

Advantage of the first condition: Program organization, modifiability (everything associated with a data structure is together), and separate compilation Advantage the second condition: Reliability-by hiding the data representations, user code cannot directly access objects of the type or depend on the representation, allowing the representation to be changed without affecting user code

Where are all Java methods defined?

All Java methods are defined in a class

Why does Java not have destructors?

Because Java has an implicit garbage collection which stores all objects which was supposed to be destroyed .

What is one reason Java does not have friend functions or friend classes?

Because java has less need for explicit friend declarations

What are the differences between a C++ struct and a C# struct?

C# also structs, but they are very different from those of C++. In C#, structs are, in a sense, lightweight classes. They can have constructors, properties, methods, and data fields and can implement interfaces but do not support inheritance.

_____provide naming encapsulations._____, they are named packages; _____, they are namespaces; _____, they are modules.

C++, C#, Java, Ada, and Ruby ; For Ada and Java ; for C++ and C# ; for Ruby

_____provide support for parameterized ADTs

C++, Java 5.0, and C# 2005

Many contemporary languages, including _____, directly support abstract data types

C++, Objective-C, Java, and C#

What are the language design issues for abstract data types

Can abstract types be parameterized? What access controls are provided? Is the specification of the type physically separate from its implementation?

In what different places can the definition of a C++ member function appear?

Complete definition of a member function appears in the class or only header of a member function appears in the class

What is the name of all Ruby constructors?

Constructors in Ruby are named initialize .

Describe the fundamental differences between C# structs and its classes.

In C#, structs are, in a sense, lightweight classes. They can have constructors, properties, methods, and data fields and can implement interfaces but do not support inheritance. One other important difference between structs and classes in C# is that structs are value types, as opposed to reference types. They are allocated on the run- time stack, rather than the heap. If they are passed as parameters, like other value types, by default they are passed by value. All C# value types, including all of its primitive types, are actually structs. Structs can be created by declaring them, like other predefined value types, such as int or float. They can also be created with the new operator, which calls a constructor to initialize them.

What are the legal return types of a constructor?

Neither constructors nor destructors have return types, and neither use return statements. Both constructors and destructors can be explicitly called .

_____ data abstractions are similar to those of C++, except all objects are allocated _____ and are accessed _____. Also, all objects are _____.

Java, from the heap, through reference variables, garbage collected

What is multiple inheritance?

Multiple inheritance allows a new class to inherit from two or more classes

____ and ____ are the two kinds of abstractions in programming language

Process abstraction, data abstraction

Nested subprograms are supported in _____

Python, JavaScript, and Ruby

The concept of data abstraction had its origins in _____

SIMULA 67

Describe briefly the eight design issues used in this chapter for object- oriented languages.

The Exclusivity of Objects Are Subclasses Subtypes? Type Checking and Polymorphism Single and Multiple Inheritance Object Allocation and Deallocation Dynamic and Static Binding Nested Classes Initialization of Objects

In Java, restrictions can be specified on the range of classes that can be passed to the generic method as generic parameters. Such restrictions are called ____. bound non-free polymorphic wildcard primitive

bound

Program units that use a specific abstract data type are called _____

clients of that type

___ is a subprogram and the referencing environment where it was defined. class object parameter template interface closure method

closure

____ is the process by which a compiler automatically converts a value of one type into a value of another type when that second type is required by the surrounding context. casting coercion auto-type defaulting auto-typing

coercion

The data defined in a C++ class are called _____; the functions (methods) defined in a class are called _____.

data members, member functions

A class that is defined through inheritance from another class is a _____ or _____ .

derived class, subclass

Stack dynamic instances of classes in C++ are always created by the _____. The lifetime of such a class instance ends when _____ .

elaboration of an object declaration, the end of the scope of its declaration is reached

In C#, a(n) ____ subroutine is an instance of a delegate type. first-class second-class third-class fourth-class parametric polymorphic subclass ad-hoc

first-class

_____ polymorphism is usually, though not always, implemented by creating multiple copies of the polymorphic code, one specialized for each needed concrete type. ad-hoc generic inheritance subtype supertype

generic

Accessor methods, sometimes called _____, allow clients indirect access to the so- called hidden data

getters and setters

Like Java, all C# class instances are _____

heap dynamic

Where are Java classes allocated?

in a single syntactic unit

As an extension of the module-as-type approach to data abstraction, many languages now provide a class construct for object-oriented programming. To first approximation, classes can be thought of as module types that have been augmented with a(n) _____ mechanism. type abstraction inheritance encapsulation polymorphism

inheritance

All of the instances of a C++ class share a single set of _____, but each instance has its own set of the _____ .

member functions, class's data members

The subprograms that define the operations on objects of a class are called _____. The calls to methods are sometimes called _____. The entire collection of methods of an object is called the _____, or _____, of the object.

methods, messages, message protocol, message interface

Heap dynamic class instances in C++ are created with the _____ and destroyed with the___

new operator, delete operator

An instance of an abstract data type is called an ____

object

Function object or functor is another name for ____ time to time. abstract class parametric object polymorphic object standard template object subtype class object closure object template

object closure

To implement a(n) ___ in C++, an object of a class that overrides operator ( ) can be called as if it were a function. abstract class parametric object polymorphic object standard template object subtype class object closure object template

object closure

____ polymorphism is provided by a subprogram that takes generic parameters that are used in type expressions that describe the types of the parameters of the subprogram. ad-hoc inheritance parametric abstract general

parametric

A class from which the new class is derived is its _____ or _____

parent class, superclass.

A _____ can be defined in a class that is able to reference (or point to) objects of the class and objects of any of its descendants

polymorphic variable

In Java (versus C++), generic parameters must be classes—they cannot be ____ types. free subtype polymorphic generic primitive

primitive


Ensembles d'études connexes

HTH 3503 Theories of Health Behavior Exam 2 Review

View Set

GEO401 - Chapter 4: Igneous Rocks

View Set

Introducing Lifespan Development Quiz

View Set

Chapter 41: Sexually Transmitted Infections-Patho http://thepoint.lww.com/Book/Show Level 3

View Set