OOP Final

¡Supera tus tareas y exámenes ahora con Quizwiz!

Java uses "garbage collection" for memory management. Which of the following are true about garbage collection in Java?

* Garbage collection is used to reclaim memory occupied by objects that are no longer accessible to a program *Garbage collection is an old idea but is now possible in languages such as java because of the speed of modern computers.

Which of the following are true for the key word null in Java?

* Null is a value stored in a variable, not a pointer to something else *It is illegal to involke a method using a null reference

Select all of the following that are listed in the reading as benefits of using generics.

* Stronger type checks at compile time * Elimination of casts * Enabling programmers to implement generic algorithms

Suppose that Kumquat is the name of a class and that fruit is a variable of type Kumquat. What is the meaning of the statement "fruit = new Kumquat();"? That is, what does the computer do when it executes this statement? (Select the options that are true)

* a new object is made of type Kumquat and stored on the heap * fruit is a reference to the new Kumquat * the default constructor of the type Kumquat is executed

Which of the following are true concerning the terms subclass and superclass?

* a subclass inherites member variables and methods from its superclass *a subclass is also know by the term derived class *several classes can be declared as subclasses of the same superclass

The catch( ) statement is used to catch an exception of any type.

...

What is the result of the following program? void test( ) { static int x = 1; cout << x++; } void main( ) { test( ); test( ); test( ); }

111

Object-oriented programming uses classes and objects. What is the relationship between classes and objects?

A class is a kind of factory, or blueprint, for constructing objects

A "Class Template Specialization" is:

A class made from a class template

Works as a bridge between two incompatible interfaces. Involves a single class which is responsible to join functionalities of independent or incompatible interfaces.

Adapter

A "Owns" B = ___________________: B has no meaning or purpose in the system without A.

Aggregation

Synonyms of "Inheritance"

An "is a" relationship Generalization Sub classing

Multiple inheritance can cause confusion in C++ when multiple base classes have methods with the same signature. To fix the issue the method should:

Be overridden in the derived class

What is the difference between memory management in C++ and C#?

C# uses references instead of pointers. C++ uses pointer. In order to deallocate memory in c++, you use the keyword delete. However, in C#, if there is nothing pointing to an object, it gets thrown in the garbage(auto garbage collection).

"Parameterized Type" is another name for

Class Templates

A "Uses" B = ___________________: B exists independently (conceptually) from A.

Composition

Grouping data and operations together that belong together.

Encapsulation

The ___________________ programming paradigm has a flow where the program responds actions from users, sensors, or other programs.

Event-driven

Creates an object without exposing the creation logic to the client and refer to newly created object using a common interface.

Factory

Access specifiers in C# are only applied to methods. True or False?

False

An explicit case is necessary when assigning a base-pointer to a derived-pointer. True or False?

False

Friendship can be extended to a template. True or False?

False

To make an abstract class in Java the programmer should label one or more of its methods as pure virtual. True or False?

False

What is the difference between classes and structs in C++ and C#?

In C++, by default, everything in a struct in public. Everything in a class in private. However, in C#, structs are value types and classes are reference types. Structs are stored on the stack, while classes are stored on the heap.

The design principle that keeps parts of a class definition concealed from the users of the type to prevent unintended coupling and potential improper use.

Information Hiding

What are instance variables and instance methods?

Instance variables are contained by an object and instance methods operate on these variables

To make an object of a class.

Instantiate

What is the singleton design pattern? Briefly describe what must be done to implement the pattern in c++.

It is where you can only make an object once from a class. You need to make the copy constructor and = operator private. You need to implement a method to make it only get one instance.

_________ provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Iterator

In this example what does myMap refer to?

Map<String, List<String>> myMap = new HashMap<>();

Can operator overloading change the meaning of how an operator works for objects of built-in types?

No

When calling a virtual function the program will choose the correct implementation according to which of the following:

Object type

The ability for objects of different classes related by inheritance to respond differently to the same member function call is:

Polymorphism

A ________________ in C# contains a getter and setter from a data members of a class.

Property

Synonyms of "Base Class"

Super Class/Parent Class

The key word _____________________, followed by a variable, is used to initiate an exception.

Throw

A method is polymorphic if the action performed by the method depends on the actual type of the object to which the method is applied. True or False?

True

An explicit cast is necessary when assigning a derived-pointer to a base-pointer. True or False?

True

Private data members can be accessed from both private and public methods. True or False?

True

_____________ is a Java compiler's ability to look at each method invocation and corresponding declaration to determine the type argument (or arguments) that make the invocation applicable.

Type inference

___________ represents an operation to be performed on the elements of an object structure. It lets you define a new operation without changing the classes of the elements on which it operates.

Visitor

When defining a class named C, how do you know if another class will inherit from C?

You cannot know

Which of the following cannot be overloaded?(SATA) a) . b) .* c) :: d) ?: e) ( )

a) . b) .* c) :: d) ?:

Which statement is true about the following code segment? const int X = 5; void main( ) { int X = 19; cout << X << ::X; } a) 5 will be sent to the console. b) 19 will be sent to the console. c) the declaration of X in main will cause a compile error. d) Truing to print X will result in an "ambiguous X" compiler error. e) A runtime error will occur.

a) 5 will be sent to the console.

What type of constructor is the following? C::C(int x = 1) {} (SATA) a) Default b) Conversion c) Copy d) Innumerable e) Explicit f) Move

a) Default b) Conversion

A class is guaranteed to have a v-table when: SATA a) It is derived from an abstract base class. b) It is derived from a concrete class. c) It is used as a base class. d) It has a data member which itself contains virtual functions. e) It has a virtual method.

a) It is derived from an abstract base class. e) It has a virtual method.

Protected attributes of class C can be accessed directly from? SATA a) Methods of class C b) Methods on any class c) Methods of class C's children d) Any function e) Global scope

a) Methods of class C c) Methods of class C's children

Which of these statements are true about concrete types? SATA a) Objects can be made from them b) Pointers of these types can point to objects c) Other classes can inherit from them d) They must be children of another type e) They must have one or more pure virtual methods

a) Objects can be made from them b) Pointers of these types can point to objects c) Other classes can inherit from them

Which of the following are associated with polymorphic behavior? SATA a) Run-time b) Compile-time c) Dynamic d) Static e) Early binding

a) Run-time c) Dynamic

A software development process in which the smallest testable parts of an application are individually and independently scrutinized for proper operation. a) Unit testing b) Regression testing c) Functional testing d) Integration testing e) Acceptance testing

a) Unit testing

In C++, friendship can be extended to (SATA): a) functions b) objects c) classes d) methods of a class e) pointers

a) functions c) classes d) methods of a class

When two functions of the same name have differing types in their parameter lists; the functions are called: a) overloaded b) overriden c) overwhelmed d) overrun e) overdue

a) overloaded

Private data members of a class can be accessed from: (SATA) a) private methods of the same class b) public methods of the same class c) friend functions of the class d) member functions of friend classes e) anywhere in the program

a) private methods of the same class b) public methods of the same class c) friend functions of the class d) member functions of friend classes

When using protected inheritance, which members of the base class become protected in the derived class? SATA a) public b) protected c) private d) Friend e) None of the above

a) public b) protected

To rethrow an exception named e, the exception handler can: SATA a) throw; b) rethrow; c) return; d) throw e; e) return e;

a) throw d) throw e;

Stack, queue and priority_queue are container ____________ . They are not first-class containers, because they do not provide the actual data-structure implementation in which elements can be stored and because they do not support iterators.

adapters

STL __________________ are functions that perform such common data manipulation operations such as searching, sorting, and comparing elements (or entire containers).

algorithms

The STL's _________________ containers provide direct access to store and retrieve elements via keys.

associative

One of the fundamental principles of good software engineering is to separate ________________ from implementation. This makes it easier to modify programs. a) Initialization b) Interface c) Construction d) Linking e) Validation

b) Interface

Which of these statements are true about abstract types? SATA a) Objects can be made from them b) Pointers of these types can point to objects c) Other classes can inherit from them d) They must be children of another type e) They must have one or more pure virtual methods

b) Pointers of these types can point to objects c) Other classes can inherit from them e) They must have one or more pure virtual methods

In C++, function ____________ are used to allow the compiler to generate a specialization to handle calls with different types of parameters. a) Pointers b) Templates c) Parameters d) Arguments e) Models

b) Templates

When declaring a class if no member access specifiers are provided: a) all members will default to public b) all members will default to private c) all members with default to protected d) the code will not compile e) a runtime error with crash the program

b) all members will default to private

When the try block throws an exception: a) all the catch handlers immediately following the try block are executed b) all subsequent code is skipped and the stack is unwound until a catch is found that matches the data type of the execution that was thrown c) the function unexpected is always called d) program execution halts eminently e) program execution continues at the next line of code

b) all subsequent code is skipped and the stack is unwound until a catch is found that matches the data type of the execution that was thrown

A member-wise(shallow) copy: a) can be trusted as long as the class contains no static or const data members b) can be trusted as long as the class contains no reference of pointer data members. c) can always be trusted. d) can never be trusted. e) must be written explicit by the programmer.

b) can be trusted as long as the class contains no reference of pointer data members.

To keep one of the auto-generated class methods from being created the programmer can place the method prototype in the class definition with what keyword? a) new b) delete c) explicit d) verbose e) auto f) no_auto

b) delete

A class member variable that needs to be changed even in const methods is declared: a) const b) mutable c) public d) static e) private

b) mutable

Which of the following is a valid use of the scope resolution operator? (SATA) a) to get a local variable b) to get a global variable when a local variable has hidden it c) to get to a function or variable within a given name-space such as std. d) to get to a public static member variable of a class. e) to get to a public const member variable of a class

b) to get a global variable when a local variable has hidden it c) to get to a function or variable within a given name-space such as std. d) to get to a public static member variable of a class. `

To declare a ______________ type parameter, list the type parameter's name, followed by the extends keyword, followed by its upper bound.

bounded

Which of the following should be returned from a method like "fun1" to allow cascaded function calls? For example: Object.fun1( ). fun2( ); a) this b) &this c) *this d) ::this e) none of the above

c) *this

What is the result of the following program? void main ( ) { int* p = new int; *p = 99; cout << *&*p; } a) It will not compile. b) A runtime error c) 99 d) The address of p e) The address that p points to

c) 99

Given int* p[10]; what is p? a) An array of 10 integers b) A pointer to an array of 10 integers c) An array of 10 integer pointers d) A reference to an array of 10 integers e) All of the above

c) An array of 10 integer pointers.

Every object has access to itself through the reserved word this. Given a class Dog, how is this implicitly declared for non-const methods? a) const Dog this; b) const Dog* const this; c) Dog* const this; d) Dog&this; e) Dog&* this;

c) Dog* const this;

Why would a programmer choose to overload an operator for type T as a non-member function? a) It is the ternary operator. b) The operator must work with an rValue of another type that can be converted to type T. c) The operator must work with an lValue of another type that can be converted to type T. d) The operator must be const. e) The operator is unary.

c) The operator must work with an lValue of another type that can be converted to type T.

const objects: a) require a const constructor to be defined b) require a const destructor to be defined c) can only make use of its const methods d) must be defined as static e) can only make use of its static methods

c) can only make use of its const methods

What types of variables are "dereferenced" to get their values? (SATA) a) static b) const c) pointer d) reference e) iterator

c) pointer e) iterator

Const and reference data members of a class should be initialized in: a) the class definition b) the body of a constructor c) the member initialization list d) the same file containing the main function e) in the implementation file, looks like a re-declaration using the scope resolution operator

c) the member initialization list

Generics add stability to your code by making more of your bugs detectable at ____________ time.

compile

To keep an overloaded type cast operator from being used unintentionally the operator should be defined using the keyword: a) Implicit b) Intentional c) Dependent d) Explicit e) Verbose

d) Explicit

In the expression int (v*)(int)(int) v is a: a) Lambda expression b) Const method c) Functor d) Pointer to a function e) Immutable

d) Pointer to a function

Which of the following variable declarations is a reference to an integer pointer? a) int p; b) int& p; c) int* p; d) int*& p; e) int&*p;

d) int*&p;

A class member variable that needs to share the same value for all objects of a given class is declared: a) const b) mutable c) public d) static e) private

d) static

The STL class template __________________ provides efficient insertions and deletions at the the front a back of the list and efficient access to any element.

deque

Which statement(s) below are true concerning functions with default parameters? a) Default parameters must be the rightmost(trailing) arguments in a function parameter list. b) Default arguments must be specified with the first occurrence of the function signature - typically in the prototype. c) Default values can be constants, global variables or function calls. d) Default arguments are allowed for parameters in class constructors. e) All of the above

e) All of the above

Static data members of a class should be initialized in: a) the class definition b) the body of a constructor c) the member initialization list d) the same file containing the main function e) in the implementation file, looks like a re-declaration using the scope resolution operator

e) in the implementation file, looks like a re-declaration using the scope resolution operator

When using private inheritance, which members of the base class become protected in the derived class? SATA a) public b) protected c) private d) friend e) none of the above

e) none of the above

_____________________ are objects used to access elements within the STL containers. These objects are often used as if they are pointers to walk through the elements of a container but they hold extra state information sensitive to the particular container.

iterators

The STL class template _____________ is implemented as a linked list and provides an efficient implementation for insertions and deletions anywhere.

list

The method _________ is static in C# and Java so it can accessed from outside the class.

main

___________ is the STL associative container that is most similar to a "dictionary". It provides a 1 to 1 mapping between a key and a value.

map

In C# an object is only created from a class when the key word ________ is used.

new

Will this syntax compile? Box<Double> box = new Box<Double>(); Box<Number> box2 = box;

no

A ______________ type is the name of a generic class or interface without any type arguments.

raw

STL ______________ containers include vector, list and deque.

sequence

A _________________ constructor in C# is used to initialize class data members rather than instance data members.

static

The reason __________ exists is so you can get access to things in the superclass that are hidden by things in the subclass.

super

When we are working inside a class and you use a simple name to refer to an instance variable like test1, where is the object that contains the variable?

this

Generics enable _____________ to be parameters when defining classes, interfaces and methods.

types

By convention, type parameter names are single, _______________ letters.

uppercase

The STL class template ________________ is a data structure that provides contiguous memory locations that allows for efficient direct access to element in the list using subscripts [].

vector

Will the following syntax compile: Box<Number> box = new Box<Number>(); box.add(new Integer(10)); box.add(new Double(10.1));

yes


Conjuntos de estudio relacionados

TestOut Ethical Hacker Pro Final Review (Labs)

View Set

8th Grade Science - Astronomy 1-2

View Set

Ch.10 - Virtualization, Cloud Computing, and Printers

View Set

Physics and Math 1.3 Displacement and Velocity

View Set

REAL ESTATE PRE-LICENSE STUDY GUIDE

View Set