• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 8 páginas
Examen

CPSC 2150 - Exam 2 Terms || Already Graded A+.

Document preview thumbnail
Vista previa 2 fuera de 8 páginas

Interface correct answers a place to specify a contract; provides a separation of concerns between class users and implementers; express some coherent concept like stacks, queues, sets and provides the methods and contracts for each How are Lists related to interfaces? correct answers Lists are interfaces in Java. It gives the contracts/methods that exist for all Lists, such as ArrayList, which is a class that implements this interface. ArrayList has all of the methods specified in the List interface. What are the two biggest reasons to use interfaces? correct answers Information hiding and separation of concerns Why are classes ineffective at information hiding compared to interfaces? correct answers Classes don't hide well; users are still burdened to look at all the class details. When classes change, user understanding is affected, and Javadocs/contracts provide only a partial solution because the explanations of public class methods may refer to private data/code. Why are classes ineffective at providing solutions to general problems? correct answers Classes provide SPECIFIC solutions to a SPECIFIC problem. It has private data and methods based on this private data. Why is it beneficial to have multiple classes implement the same interface? correct answers Performance trade-offs (speed vs. memory efficiency); alternative class implementation offers more choice to users that allow users to adapt to their needs based on the interface and classes within that interface If we have an interface Grid, and two classes GridMem and GridFast that implement Grid, how would calling myGdA() work? correct answers Since GridMem and GridFast have the same list of methods, myGdA() will work because methodA() is defined for both classes through the interface. It doesn't matter that our classes are different here since the code is based on the interface. Write Java syntax for an interface Salaried that 1) has a setSalary function that takes in a BigDecimal and returns nothing, and 2) has a getSalary function with no parameters of type BigDecimal. Then, explain the two features that a class inheriting Salaried must have to satisfy the interface. correct answers public interface Salaried{ void setSalary(BigDecimal d); BigDecimal getSalary(); } Two features include 1) matching signatures (checked by compiler) and 2) matching behaviors (up to programmer). What are the three main qualities necessary to declaring an interface? correct answers 1) Keyword "interface" replaces "class" 2) Methods have no body 3) There are no constructors


Información del documento

Subido en
25 de marzo de 2024
Número de páginas
8
Escrito en
2023/2024
Tipo
Examen
Contiene
Preguntas y respuestas
$11.79

¿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.
ProPerfomer
3.8
(84)
Vendido
451
Seguidores
322
Artículos
8858
Última venta
2 días 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

Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.