Q1. Is it always necessary to implement data hiding and encapsulation in a program? Explain with the help of an example in case yes or no.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Use only java programming language.please give answer briefly and authentic with example according to the given question?

Q1. Is it always necessary to implement data hiding and encapsulation in a program? Explain with the
help of an example in case yes or no.
Q2. Class Citizen holds two states i.e., “çnic" of type integer and “name" of type String, and a setter
and getter method of type void and integer respectively that sets and retuns the name state. An object
of class Citizen is created in another class that holds main method. Explain what size is reserved for
both classes in the memory.
Q3. Why we need multiple constructors and multiple methods of the same name in a class? Provide an
example to justify your answer.
Q4. There are four states in a class Pen. These states are “color" of type String, "ink" of color String,
"manufacturer" of type String, and "inkThickness" of type double. How many setter and getter methods
you need in this class and why? Which states can be made private and why?||
Transcribed Image Text:Q1. Is it always necessary to implement data hiding and encapsulation in a program? Explain with the help of an example in case yes or no. Q2. Class Citizen holds two states i.e., “çnic" of type integer and “name" of type String, and a setter and getter method of type void and integer respectively that sets and retuns the name state. An object of class Citizen is created in another class that holds main method. Explain what size is reserved for both classes in the memory. Q3. Why we need multiple constructors and multiple methods of the same name in a class? Provide an example to justify your answer. Q4. There are four states in a class Pen. These states are “color" of type String, "ink" of color String, "manufacturer" of type String, and "inkThickness" of type double. How many setter and getter methods you need in this class and why? Which states can be made private and why?||
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY