CMSC 132 Exam review(Accurately solved)
What do you find in a java interface? correct answers method prototypes, final static variables, static methods (note: instance methods are ok if you use the term 'default'). The classes that implement an interface must implement ___________ correct answers Instance methods from interface (note: default instance method does not need to be implemented, it has already been inherited). When should you use the key word 'Override'? correct answers When you are implementing a method from an interface. If there is default implementation of a method you can use override to implement it differently. (reminder: if it is already implemented in the interface, you do not need to implement it in a different class because it has already inherited it). (T/F) - You can add other code to the classes that inherit the superclass features aside from the interface method implementations. correct answers TRUE (T/F) you cannot create polymorphic collections correct answers FALSE What does API stand for and what is it? correct answers Application Programming Interface, the API is part of a model that are exposed to the user (public features). For example, when you write projects you use the String class, it has an API which are the features from that class available to users. Overall in an API you find public variables, public methods, and the contracts of the methods. What did Fawzi mention is important to remember in regards to the API? correct answers When changing code, make sure to leave the API the same so the outside user doesn't have anything to worry about. What is encapsulation? correct answers Hiding something in a private shell, in order to access private members they use public methods. What are the 2 types of encapsulation? What do they each mean? correct answers data encapsulation - make the data private procedural encapsulation - switching out an algorithm behind the scenes and no user will know (rule of thumb: encapsulate what may change later). Why do the wrapper classes exist? correct answers In order to make collections of these values. Collections can only collect objects, not primitives. (T/F) all the wrapper classes are immutable. correct answers TRUE. You cannot change the state of the object. Which declaration is correct? a) Integer x = new Integer(7);
Written for
- Institution
- CMSC 132
- Module
- CMSC 132
Document information
- Uploaded on
- May 29, 2024
- Number of pages
- 23
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
what do you find in a java interface
Also available in package deal