
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Number 22

Transcribed Image Text:580
Chapter 8 Classes
Section 8.3: Object Initialization: Constructors
17. What is a constructor? How is a constructor different from other methods?
18. What are two major problems with the following constructor?
public void Pointfint initialx, int initialy) (
int
initial;
int y initial;
)
19. (You must complete Self-Check Problem 7 before answering this question.)
Add a constructor to the same class that accepts a first name, middle initial, and last name as parameters and
initializes the same object's state with those values.
21. Add a constructor to the Point class that accepts another Point as a parameter and initializes this new Point to
20. What is the meaning of the keyword this? Describe three ways that the keyword can be used.
have the same (x, y) values. Use the keyword this in your solution.
Section 8.4: Encapsulation
22. What is abstraction? How do objects provide abstraction?
23. What is the difference between the public and private keywords? What items should be declared private?
24. When fields are made private, client programs cannot see them directly. How do you allow classes access to read these
fields' values, without letting the client break the object's encapsulation?
25. Add methods named setx and sety to the point class that allow clients to change a Point object's x-and
y-coordinates, respectively.
26. (You must complete Self-Check Problem 7 before answering this question.)
Encapsulate the Name class. Make its fields private and add appropriate accessor methods to the class.
27. (You must complete Self-Check Problem 26 before answering this question.)
Add methods called setFirst Name, setMiddleInitial, and setLastName to your Name class. Give the para
eters the same names as your fields, and use the this keyword in your solution.
28. How does encapsulation allow you to change the internal implementation of a class?
Section 8.5: Case Study: Designing a Stock Class
29. What is cohesion? How can you tell whether a class is cohesive?
30. Why didn't we choose to put the console I/O code into the Stock class?
31. Add accessor methods to the stock class to return the stock's symbol, total shares, and total cost.
Exercises
1. Add the following accessor method to the Point class:
public int quadrant ()
Returns which quadrant of the x/y plane the current Point object falls in. Quadrant 1 contains all points whose x
and y values are both positive. Quadrant 2 contains all points with negative x but positive y. Quadrant 3 contains a
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps

Knowledge Booster
Similar questions
- In what numbering system are all numbers represented by a string of zeroes and ones?arrow_forwardTask 1 Sum the following numbers expressed in their respective bases: 11001100112 52014378 93D462C16 Convert your answer to Hexadecimal.arrow_forwardIn what numbering system are all numbers represented by a string of zeroes and ones?arrow_forward
- What is the least common multiple of 24 and 36? Show your work.arrow_forwardThe sum of three numbers is 98. The third number is 4 times the second. The first number is 10 less than the second. What are the numbers in binary number system?arrow_forwardI'm not sure how to make a table showing hexadecimal numbers between 0X00 and 0X20 and their binary equivalants. Thanks for your help.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY