Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

class ClockType { public void setTime(int hour, int min, int sec); public int ge

ID: 667681 • Letter: C

Question

class ClockType
{
public void setTime(int hour, int min, int sec);
public int getTime();
public void printTime();
public void incrementSeconds();
private int hr;
public int min;
public int sec;
}


1. (TCO 1) A class is a _____, which encapsulates _____ and _____. (Points : 2)        programming language construct; attributes; behavior
       field; objects; members
       template; methods; behavior
       All of the above
       None of the above Question 2.2. (TCO 1) Which of the following would be the most appropriate choice for a method in a Fork class?
(Points : 2)        color()
       bend()
       eat()
       material() Question 3.3. (TCO 1) Which of the following statements is/are true? (Points : 2)        A. Objects communicate through message passing.
       B. An object must be defined before you can create a class.
       C. The state of an object should not be hidden.
       D. Implementation details should be visible through the interface of a class.
       A and C
       All are true
       None are true Question 4.4. (TCO 1) Which of the following would be the most appropriate choice for a data member in a Screen class? (Points : 2)        dimensions
       turnOff
       refresh
       activateScreenSaver Question 5.5. (TCO 1) The following is/are object-oriented programming feature(s): (Points : 2)        Ease of Use
       Implementation
       Abstraction
       All of the above
       None of the above Question 6.6. (TCO 8) Most professional coding standards use _____ for class names. (Points : 2)        underscores along with all upper case words
       Method Class case
       no specific naming convention
       Pascal case Question 7.7. (TCO 1) Examine the ClockType class definition. How many methods does it contain?

class ClockType
{
public void setTime(int hour, int min, int sec);
public int getTime();
public void printTime();
public void incrementSeconds();
private int hr;
public int min;
public int sec;
}

(Points : 2)        7
       3
       10
       4
       An average of 5 because (7 + 3) / 2 = 5 Question 8.8. (TCO 1) Assume we have two classes and have instantiated an object from each class. How many copies of each class's attributes and methods exist in the instantiated objects? (Points : 2)        Two copies, one copy of the first class and one of the second
       Zero, the objects do not have attributes and methods
       Only one copy and both objects share it
       None of the above Question 9.9. (TCO 1) Inheritance is referred to as a(n) _____ relationship, while composition is referred to as a(n) _____ relationship. (Points : 2)        superclass-subclass ; friend
       Is-a; Has-a
       Has-a; Is-a
       None of the above Question 10.10. (TCO 1) Which of the following is a valid statement for a method definition in Java? (Points : 2)        public int computeAverage {
    return 1;
}
       public int computeAverage (
     return 1;
)
       public int computeAverage () {
     return 1;
};
       public int computeAverage () {
          return 1;
      }

Explanation / Answer

1.

d) all of the above

2)

it should be eat as it will behave like fork

3)

A and C are true

4)

turn off

5)

All of above

6)

underscores along with all upper case words

7)

4

8)

two copies

9)

is-a;has-a

10)

  public int computeAverage () {
     return 1;
};