Question 1.1. (TCO 1) Which of the following statements is/are true? (Points : 5)

 

       A. The implementation of a class should be hidden, as best practice.

 

       B. The state of an object is defined as the attributes and behaviors of that object.

 

       C. Striving for the fullest possible interface of a class, incorporating possible future class needs, is the goal when designing a class.

 

       D. An interface of a class defines what messages an object can respond to.

 

       All are true

 

       None are true

 

       Only A and D are true

 

 

 

 

 

Question 2.2. (TCO 2) Which of the following components of a class definition can be overloaded? (Points : 5)

 

       Any object

 

       Constructor

 

       Static data members

 

       All of the above

 

       None of the above

 

 

 

 

 

 

 

Question 3.3. (TCO 5) Which of the following method pairs are not examples of method overloading? (Points : 5)

 

       public void dance()

 

public int dance(int x)

 

       public int walk(int x, int y)

 

public void walk(int x, int y, int z)

 

       public int jump(int x, int y)

 

public void jump(int y, int x)

 

       All of the above

 

       None of the above

 

 

 

 

 

Question 4.4. (TCO 1) Which of the following statements is/are true? (Points : 5)

 

       You can create sub-classes and sub-objects.

 

       By using the keyword class in your program, memory is allocated for the object being defined.

 

       In object-oriented programming we design the program as a set of cooperating methods.

 

       None of the above

 

 

 

 

 

Question 5.5. (TCO 1) Which of the following would be the most appropriate choice for a method in a Computer class? (Points : 5)

 

       monitorSize

 

       reboot

 

       processorType

 

       keyboard

 

 

 

 

 

Question 6.6. (TCO 2) Which of the following statements is/are true? (Points : 5)

 

       A. The compiler generated default constructor does the exact same job as any user defined default constructor

 

       B. A common use of information hiding is to hide the physical storage layout of data.

 

       C. A private (helper) method is part of a class's implementation.

 

       All of the above

 

       Only B and C

 

 

 

 

 

Question 7.7. (TCO 2) You are given a Shape class that was designed with the concept of a black box in mind. You need to integrate the Shape class into your own code. Which of the following statements are true? (Points : 5)

 

       You need to analyze each method's implementation that you plan to use in order to understand it thoroughly.

 

       You need to figure out the inputs and outputs that are associated with the class.

 

       You may have to modify the internal processing to meet the needs of your specific class.

 

       Without a properly constructed UML diagram you cannot be sure how the new class will integrate with your code.

 

 

 

 

 

Question 8.8. (TCO 2) Given a private string attribute called homeState, which of the following are proper pseudocode implementations for a getter and a setter? (Points : 5)

 

       string getHomeState(){return homeState }

 

int setHomeState(string newHomeState){return homeState }

 

       void getHomeState(){return homeState }

 

void setHomeState (int newHomeState){homeState = newHomeState}

 

       string getHomeState(){return homeState }

 

void setHomeState (string newHomeState){ homeState = newHomeState}

 

       string getHomeState (){homeState = newHomeState}

 

void setHomeState (string newHomeState){ homeState = newHomeState}

 

 

 

 

 

Question 9.9. (TCO 2) You are tasked to create an EntertainmentSystem class and you want to minimize data dependencies. You also need to protect specific attributes from outside entities. What object-oriented concept(s) would you use to accomplish these goals? (Points : 5)

 

       Composition of classes

 

       Universal access to methods

 

       Inheritance

 

       Encapsulation

 

       All of the above

 

 

 

 

 

 

 

Question 10.10. (TCO 4) Select the false statement regarding inheritance.

 

(Points : 5)

 

       A child class can have more functionality than parent class.

 

       A child class can itself be parent class.

 

       Common functionality needs to be designed in the parent class.

 

       Parent classes are usually more specific than child classes.

 

 

 

 

 

 

 

Question 11.11. (TCO 4) A Lamp class, LightBulb and OilLamp class have what type of relationships?

 

(Points : 5)

 

       The Lamp is a LightBulb, and the Lamp is an OilLamp.

 

       The LightBulb has an OilLamp, and the OilLamp is a Lamp.

 

       The Lamp has a LightBulb, and the OilLamp is a Lamp

 

       The LightBulb has an OilLamp, and the Lamp is an OilLamp.

 

 

 

 

 

 

 

Question 12.12. (TCO 3) Which of the following is true about identifying a class based on a set of requirements?

 

(Points : 5)

 

       After the requirements are documented, the process of identifying classes can begin.

 

       One way to identify classes is to identify nouns in the problem analysis.

 

       Responsibilities of each class need to be identified after classes are identified.

 

       All of the above

 

 

 

 

 

Question 1.1. (TCO 3) What does SOW stand for in the object-oriented design process?

 

(Points : 5)

 

       Sequence of work

 

       Structure of work

 

       Statement of work

 

       None of the above

 

 

 

 

 

 

 

Question 2.2. (TCO 4) What are the benefits to create another derived class instead of adding new functionalities to the program?

 

(Points : 5)

 

       Saves time on debugging the program

 

       Simplifies testing

 

       No need to re-test the previously written class

 

       All of the above

 

       None of the above

 

 

 

 

 

 

 

Question 3.3. (TCO 6) What is polymorphism?

 

(Points : 5)

 

       An advanced form of inheritance

 

       A single usefulness for program specificity

 

       One interface, many implementations

 

       Data hiding

 

 

 

 

 

Question 4.4. (TCO 7) Which of the following statements are false? (Points : 5)

 

       Interfaces specify a contract that must be respected by programmers implementing the interface.

 

       Interfaces specify one or more method signatures and at least one implementation.

 

       Interfaces can be used in some object-oriented languages to implement a form of multiple inheritance.

 

       Interfaces are often implemented by regular classes.

 

 

 

 

 

Question 5.5. (TCO 7) In an object-oriented program, an abstract method might be found in an _____ and/or a(n) _____. (Points : 5)

 

       abstract class; base class

 

       abstract class; interface

 

       interface; base class

 

       None of the above

 

 

 

 

 

Question 6.6. (TCO 7) In terms of object-oriented programming, rules for the use of an application programming interface or framework can be enforced through the use of a(n) _____. (Points : 5)

 

       encapsulation

 

       inheritance hierarchy

 

       contract

 

       object constructed with a multi-arg constructor

 

       None of the above

 

 

 

 

 

Question 7.7. (TCO 8) Data/information hiding and encapsulation improves construction and maintenance because:

 

(Points : 5)

 

       A. Program bugs are isolated to a single class.

 

       B. Programming to an interface makes the code more logical.

 

       Both A and B

 

       None of the above

 

 

 

 

 

 

 

Question 8.8. (TCO 8) What are some of the characteristics of "self-documenting" code?

 

(Points : 5)

 

       Detailed comments, addressing all aspects of the code

 

       Deep levels of nesting to ensure all situations are addressed

 

       Straightforward algorithms

 

       All of the above

 

       None of the above

 

 

 

 

 

 

 

Question 9.9. (TCO 9) Which of the following allow a programmer to reduce the complexity of an object-oriented program?

 

(Points : 5)

 

       Create each class in a separate file

 

       Using packages as a container for logically related items

 

       Using packages to create global types

 

       All of the above

 

       None of the above

 

 

 

 

 

 

 

Question 10.10. (TCO 7) Which of the following declares an abstract method in an abstract Java class? (Points : 5)

 

       public abstract calculateTip();

 

       public abstract double calculateTip();

 

       public double abstract calculateTip();

 

       public double calculateTip() {}

 

 

 

 

 

Question 11.11. (TCO 4) Given the following class definition, which of the methods defined in ClassB would not be inherited by a derived class?

 

 

 

public class ClassB {

 

 

 

            void greatMethod(){      

 

                        System.out.println("ClassB greatMethod");

 

            }

 

           

 

            private void greatPrivateMethod(){

 

                        System.out.println("ClassB greatPrivateMethod");

 

            }

 

            

 

            public void greatPublicMethod(){

 

                        System.out.println("ClassB greatPublicMethod");

 

            }

 

} (Points : 5)

 

       greatMethod

 

       greatPrivateMethod

 

       greatPublicMethod

 

       All three methods are inherited

 

       None of the methods will be inherited

 

 

 

 

 

Question 12.12. (TCO 7) Which of the following is a proper instantiation of the abstract class show below?

 

 

 

public abstract class Mountain{} (Points : 5)

 

       Mountain newMountain = Mountain();

 

       Mountain newMountain = Mountain.mountain();

 

       Mountain newMountain = super.mountain();

 

       None of the above

 

       All of the above

 

 

 

Question 1.

1.   RspGF="font-family:'Arial';font-size:10pt;"(TCO 2) Provide an example, which shows the

 distinction between Encapsulation and Data/Information Hiding in object-oriented programming. (Points : 18)

      

      

 

 

 

Question 2.

2.   RspGF="font-family:'Arial';font-size:10pt;"(TCO 2) Keeping in mind all object-oriented

 programming best practices, create a class for a Computer, 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.

(Points : 18)

      

      

 

 

 

Question 3.

3.   RspGF="font-family:'Arial';font-size:10pt;"(TCO 2) 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.

 

LandOnStatue, NumberOfLegs, Height, ShoeSize, Eat, Animal, Speak, WingSpan, Age,

Peck, Sleep, Horse, LengthOfMane, Move, BeakLength, LengthOfTail, Bird, SaddleUp (Points : 18)

      

      

 

 

 

Question 4.

4.   RspGF="font-family:'Arial';font-size:10pt;"(TCO 2) Briefly describe what an interface is

and how it can be used in an object-oriented program. Provide example pseudocode

showing how an s Interface might be constructed.  (Points : 18)

      

      

 

 

 

Question 5.

5.   RspGF="font-family:'Arial';font-size:10pt;"(TCO 7) How do you distinguish between

abstract and normal methods?  How do you use an abstract class and the methods

defined inside it? Provide pseudocode that represents an abstract class with at least one

abstract method.

(Points : 18)

      

      

 

 

 

Question 6.

6.   RspGF="font-family:'Arial';font-size:10pt;"(TCO 2) 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

}

(Points : 18)

      

      

 

 

 

Question 7.

7.   RspGF="font-family:'Arial';font-size:10pt;"(TCO 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. (Points : 22)

      

      

 

 

 

    • 5 years ago
    THIS HAS BEEN GRADED A+ USE ONLY AS A GUIDE
    NOT RATED

    Purchase the answer to view it

    • attachment
      week_8.docx