Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 4 fuera de 272 páginas
Examen

Test Bank - Data Structures and Abstractions with Java, 5th edition by Frank M. Carrano, Chapter 1-30 , A+ Guide.

Document preview thumbnail
Vista previa 4 fuera de 272 páginas

Test Bank - Data Structures and Abstractions with Java, 5th edition by Frank M. Carrano, Chapter 1-30 , A+ Guide.

Vista previa del contenido

Chapter 1 - Bags



True/False (10)

1. An abstract data type is not necessarily a collection.

Answer: true

2. A collection is not necessarily an abstract data type.

Answer: false

3. Entries of a bag can belong to classes related by inheritance.

Answer: true

4. Entries of a bag may belong to different classes because items are unordered.

Answer: false

5. All entries of a bag must have the same data type or a subtype of that data type.

Answer: true

6. By declaring a data type to be a BagInterface, we can replace the bag class with another class
that implements the BagInterface.

Answer: true

7. A method can change the state of an object passed to it as an argument.

Answer: true

8. A set is a special kind of bag.

Answer: true

9. You cannot determine the exact number of times a particular item appears in a bag because it is
unordered.

Answer: false

10. Code written with respect to an interface makes it difficult to replace one implementation of a
bag with another.

Answer: false




SCHOLARVAULT

,Short #mgAnswer #mg(5)

1. Explain #mgthe #mgrationale #mgfor #mgreturning #mga #mgBoolean #mgvalue #mgfrom #mgthe #mg add #mgbag #mgoperation.

Answer: # m g A #mgclient #mgshould #mgknow #mgwhat #mghappened. #mgA #mgBoolean #mgvalue #mgindicates #mgtrue
#mgfor #mgsuccess #mgor #mgfalse #mgfor #mga #mgfailed #mgoperation.




2. Explain #mgwhy #mgwriting #mga #mgtest #mgprogram #mgbefore #mgimplementing #mga #mgclass #mgis #mga #mggood #mgidea.

Answer: # m g It #mghelps #mgyou #mgunderstand #mgthe #mgspecifications #mgbefore #mgcommitting #mgto #mgyour #mgdesign
#mgand #mgimplementation.




3. Explain #mgwhy #mgthe #mgset #mgADT #mgdoes #mgnot #mgneed #mga #mggetFrequencyOf #mgoperation.

Answer: # m g Because #mgsets #mgdo #mgnot #mgcontain #mgduplicate #mgitems, #mgonly #mga #mg0 #mgfor #mgabsence
#mgor #mg1 #mgfor #mgpresence #mgof #mgan #mgitem #mgwould #mgbe #mgreturned. #mgUsing #mga #mgcontains #mgmethod


#mgis #mga #mgbetter #mgdesign.




4. What #mgis #mgthe #mgdesign #mgrationale #mgfor #mgproviding #mga #mgtoArray #mgmethod #mginstead #mgof #mga

#mg displayBag #mgmethod? #mgAnswer: # m g The #mguser/client #mgis #mgfree #mgto #mgdisplay #mgany #mgor #mgall

of #mgthe #mgitems #mgin #mgany #mgway #mgdesired.
#mg




5. Explain #mgwhy #mgnull #mgis #mga #mgpotential #mgreturn #mgvalue #mgfor #mgthe #mgremove #mgoperation.

Answer: # m g It #mgis #mga #mgvalue #mgthat #mgcannot #mgbe #mgin #mgthe #mgbag #mgand #mgtherefore #mgsignals #mga
#mgproblem #mgif, #mgfor #mgexample, #mga #mgclient #mgtries #mgto #mgremove #mgan #mgentry #mgfrom #mgan #mgempty


#mgbag.




Multiple #mgChoice #mg(30) #mgWARNING: #mgCORRECT #mgANSWERS #mgARE #mgIN #mgTHE #mgSAME #mgPOSITION
#mgAND #mgTAGGED #mgWITH #mg**. #mgYOU #mgSHOULD #mgRANDOMIZE #mgTHE #mgLOCATION #mgOF #mgTHE


#mgCORRECT #mgANSWERS #mgIN #mgYOUR #mgEXAM.




1. A #mglanguage-independent #mgspecification #mgfor #mga #mggroup #mgof #mgvalues #mgand #mgoperations #mgon
#mgthose #mgvalues #mgis #mgcalled #mga/an:


a. abstract #mgdata #mgtype # m g **
b. data #mgstructure
c. collection
d. primitive

2. An #mgimplementation #mgof #mgan #mgADT #mgwith #mga #mgprogramming #mglanguage #mgis #mgcalled #mga/an:
a. data #mgstructure #mg**
b. abstract #mgdata #mgtype
c. collection
d. primitive


SCHOLARVAULT

,3. An #mgobject #mgthat #mggroups #mgother #mgobjects #mgand #mgprovides #mgservices #mgto #mgits #mgclients #mgis #mgcalled
#mga/an:


a. collection #mg**




SCHOLARVAULT

, b. abstract #mgdata #mgtype
c. data #mgstructure
d. primitive

4. Which #mgof #mgthe #mgfollowing #mgis #mgnot #mgtrue #mgwith #mgregard #mgto #mgbags?
a. objects #mgare #mgin #mga #mgspecific #mgorder #mg**
b. can #mgcontain #mgduplicate #mgitems
c. is #mgan #mgabstract #mgdata #mgtype
d. is #mga #mgkind #mgof #mgcollection #mgin #mgJava

5. Which #mgbehavior #mgis #mgnot #mgrepresented #mgin #mga #mgbag?
a. reorder #mgthe #mgbag #mg**
b. report #mgthe #mgnumber #mgof #mgitems #mgin #mgthe #mgbag
c. report #mgif #mgthe #mgbag #mgis #mgempty
d. add #mgan #mgitem #mgto #mgthe #mgbag

6. Which #mgmethod #mgreturns #mga #mgcount #mgof #mgthe #mgcurrent #mgnumber #mgof #mgitems #mgin #mga #mgbag?
a. getCurrentSize() #mg**
b. getSize()
c. size()
d. currentSize()

7. Why #mgwould #mgthe #mgadd #mgmethod #mgreturn #mgfalse?
a. when #mgthe #mgaddition #mgof #mga #mgnew #mgitem #mgwas #mgnot #mgsuccessful #mg**
b. when #mgthere #mgwas #mga #mgduplicate #mgof #mgthe #mgentry #mgalready #mgin #mgthe #mgbag
c. when #mgthere #mgwas #mgnot #mga #mgduplicate #mgof #mgthe #mgentry #mgalready #mgin #mgthe #mgbag
d. when #mgaddition #mgof #mga #mgnew #mgitem #mgwas #mgsuccessful

8. Which #mgmethod #mgremoves #mgall #mgentries #mgof #mga #mgbag?
a. clear() #mg**
b. remove()
c. delete()
d. empty()

9. Which #mgmethod #mgremoves #mgone #mgunspecified #mgentry #mgfrom #mga #mgbag #mgif #mgpossible?
a. remove() #mg**
b. clear #mg()
c. delete()
d. empty()

10. Which #mgmethod #mgremoves #mgone #mgoccurrence #mgof #mga #mgparticular #mgentry #mgfrom #mga #mgbag #mgif
#mgpossible?


a. remove(anItem) #mg**



SCHOLARVAULT

Información del documento

Subido en
26 de agosto de 2025
Número de páginas
272
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$16.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
ScholarVault
3.0
(1)
Vendido
30
Seguidores
1
Artículos
547
Última venta
1 semana hace


Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes