100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

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

Rating
-
Sold
-
Pages
8
Grade
A+
Uploaded on
25-03-2024
Written in
2023/2024

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

Show more Read less
Institution
CPSC 2150
Course
CPSC 2150









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
CPSC 2150
Course
CPSC 2150

Document information

Uploaded on
March 25, 2024
Number of pages
8
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ProPerfomer (self)
View profile
Follow You need to be logged in order to follow users or courses
Sold
432
Member since
2 year
Number of followers
322
Documents
8501
Last sold
1 day ago
Global Scholars’ Resource Hub

Welcome to your ultimate exam success hub! We provide top-quality, up-to-date, and approved exam materials—study guides, practice tests, and notes for a variety of subjects. Whether you’re preparing for school, college, or professional exams, our resources are designed to help you study smarter and score higher. Thousands have passed with our materials—now it’s your turn!Need more resources or something specific? Contact me anytime, and I’ll be happy to help you find exactly what you need. Your success is our mission!" ✅ Covers multiple subjects and exam types ✅ Includes real practice questions, answers, and study tips ✅ Ideal for students, test takers, and last-minute review Your Exam Success Starts Here – Grab Your Bundle Before It’s Gone!

Read more Read less
3.9

83 reviews

5
36
4
25
3
9
2
1
1
12

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions