Does Encapsulation imply Data/Information Hiding in object-oriented programming? Why or why not?

profileCSpro
 (Not rated)
 (Not rated)
Chat

1. Does Encapsulation imply Data/Information Hiding in object-oriented programming? Why or why not?
2. Keeping in mind all object-oriented programming best practices, create a class for a Desk, with the following specifications:
1. Specify two data members
2. Default Constructor
3. Overloaded Constructor which takes both data member values as input.
4. Generate a unique identification number for each object instantiated from this class. Use a static data member to keep track of the identification number last assigned to an object so that duplications will not occur.
5. Show a statement which instantiates an object of this class using the overloaded constructor.
You do not need to provide any accessor/mutator methods or other methods.
3. Given the following list of classes, attributes and methods,
- identify which items are classes, which items are attributes and which items are methods;
- identify which class each attribute and method belongs to; and
- suggest a class hierarchy given your list of classes.
*Note - no particular capitalization scheme is used in the list below to differentiate between classes, methods and attributes.
Brew, DecreaseTemperature, Manufacturer, MinCups, Price, TurnOff, Oven, MaxTemperature, BrewStrength, NumberOfRacks, IncreaseTemperature, TurnOn, StartTimer, CoffeeMaker, KitchenAppliance, MaxCups, YearBuilt, Grind
4. Briefly describe what an interface is and how it can be used in an object-oriented program. Provide example pseudocode showing how an iEbook Interface might be constructed.
5. What is an abstract class? What is an interface? How are abstract classes and Interfaces the same? How are they different? Finally, how do you use abstract methods defined inside an abstract class or Interface?
6. Define and implement the overloaded constructors that support the following test function for a Cube class. The data member for the Cube class is side which holds an integer.
public static void main(String args[])
{
//c1 will take all default values
Cube c1();
//c2 will take supplied side value
Cube c2(6);
//c3 will take the same value of c2
Cube c3=c2;
//the rest of the code
}
7. Create a Java Interface called Fruit that contains two method declarations: ripen and emitAroma. Create a Java class called Nectarine that implements the Fruit interface and includes two attributes: gramsOfSugar and weightInOunces. Finally, show an instantiation of the Nectarine class that sets the Nectarine's gramsOfSugar to 30 and weightInOunces to 4.

    • 9 years ago
    A+Answer - Expert solution
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      solution-102.docx