CPSC 2150 Exam 2 Review || with Accurate Answers 100%.
_________ make interfaces and classes reusable by parameterizing them correct answers Generics What is this an example of? public interface IStack <T> { public void push(T x); public T pop(); public int depth(); } correct answers Generic Interface How to instantiate a variable of type Integer? public interface IStack <T> { public void push(T x); public T pop(); public int depth(); } correct answers IStack<Integer> si = new Stack1<>(100); Java demands that generic arguments must be __________ correct answers reference types What makes an object immutable? correct answers State cannot change after is it constructed (value is constant) si = <49, 3> k = 70 (k) k = 37 What state is si and k in? Does the memory address of k change or stay the same? correct answers si = <70, 49, 3> k = 37 The memory address of k changes What happens when you use the final keyword on a reference type? correct answers Memory address can't change but data stored in that address can be changed if the object has mutable private fields Generics relies that all non-primitive types are _________ types correct answers Reference ________ allows use to reuse code, instead of making new class for each different data type correct answers Generics Any deviation of the observed behavior from the specified behavior correct answers Failure The system is in a state such that further processing of the system will result in a failure correct answers Erroneous state
Written for
- Institution
- CPSC 2150
- Course
- CPSC 2150
Document information
- Uploaded on
- March 25, 2024
- Number of pages
- 7
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
make interfaces and classes reusable by
Also available in package deal