Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS70 Quiz 5: Object-Oriented Programming Concepts, Exercises of Computer Science

The instructions and questions for quiz 5 in cse 70, a university-level object-oriented programming course offered in fall 2009. Students are required to answer questions related to various oop concepts, including pattern matching, adapter design, and the principle of least knowledge.

Typology: Exercises

2012/2013

Uploaded on 04/07/2013

sethuraman_h34rt
sethuraman_h34rt 🇮🇳

4.3

(8)

159 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Signature _____________________ CSE 70 Name ________________________
Quiz 5
cs70f ____ Fall 2009 Student ID ____________________
This quiz is to be taken by yourself with closed books, closed notes, no electronic devices.
1) Match each pattern with its description:
2) To make a Turkey look like a Duck, we need to provide an adapter interface
A) with the Turkey methods and implement them with calls to equivalent Duck methods
B) with the Duck methods and implement them with calls to equivalent Turkey methods
C) with both Turkey and Duck method and implement them with calls to each other's equivalent methods
D) that uses reflection to create a Turkey object each time the client requests a Duck object
E) that throws an UnsupportedOperationException each time the client tries to use any Duck method
F) that throws an UnsupportedOperationException each time the client tries to use any Turkey method
3) Circle the incorrect answer. According to the Principle of Least Knowledge, objects should only invoke
methods that belong to
A) the object itself
B) any object the method creates/instantiates
C) any object returned from calling other methods
D) any object passed in as a parameter to the method
E) any component of the object (for example, instance variables referencing other objects)
4) What question would you like to see on the Final Exam?
Pattern
____ Strategy
____ Adapter
____ Iterator
____ Facade
____ Composite
____ Observer
____ Template
Method
A) Clients treat collections of objects and individual objects uniformly
B) Provides a way to traverse a collection of objects without exposing the
collection's implementation
C) Simplifies the interface of a group of classes
D) Changes the interface of one or more classes
E) Allows a group of objects to be notified when some state changes
F) Encapsulates interchangeable behaviors and uses delegation to decide
which one to use
G) Defines the steps of an algorithm and allows subclasses to decide how
to implement one or more steps

Partial preview of the text

Download CS70 Quiz 5: Object-Oriented Programming Concepts and more Exercises Computer Science in PDF only on Docsity!

Signature _____________________ CSE 70 Name ________________________

Quiz 5

cs70f ____ Fall 2009 Student ID ____________________

This quiz is to be taken by yourself with closed books, closed notes, no electronic devices.

  1. Match each pattern with its description:

  2. To make a Turkey look like a Duck, we need to provide an adapter interface

A) with the Turkey methods and implement them with calls to equivalent Duck methods B) with the Duck methods and implement them with calls to equivalent Turkey methods C) with both Turkey and Duck method and implement them with calls to each other's equivalent methods D) that uses reflection to create a Turkey object each time the client requests a Duck object E) that throws an UnsupportedOperationException each time the client tries to use any Duck method F) that throws an UnsupportedOperationException each time the client tries to use any Turkey method

  1. Circle the incorrect answer. According to the Principle of Least Knowledge, objects should only invoke methods that belong to

A) the object itself B) any object the method creates/instantiates C) any object returned from calling other methods D) any object passed in as a parameter to the method E) any component of the object (for example, instance variables referencing other objects)

  1. What question would you like to see on the Final Exam?

Pattern

____ Strategy

____ Adapter

____ Iterator

____ Facade

____ Composite

____ Observer

____ Template Method

A) Clients treat collections of objects and individual objects uniformly B) Provides a way to traverse a collection of objects without exposing the collection's implementation C) Simplifies the interface of a group of classes D) Changes the interface of one or more classes E) Allows a group of objects to be notified when some state changes F) Encapsulates interchangeable behaviors and uses delegation to decide which one to use G) Defines the steps of an algorithm and allows subclasses to decide how to implement one or more steps