Answered You can hire a professional tutor to get the answer.

QUESTION

I need help to review class notes for the CS111. Can you help me?

I need help to review class notes for the CS111. Can you help me? I want to get answer before tonight.

1. Making an instance of "one class" a field in another class is called _______ .

a. nesting

b. class fielding

c. aggregation

d. concatenation

2. This enum method returns the position of an enum constant in the declaration.

a. position

b.  location

c. ordinal

d. toString

3. True or False: A static member method may refer to non-static member variables of the same class, but only after an instance of the class has been defined.

4. True or False: You can declare an enumerated data type inside a method.

5. Assume the following declaration exists :

enum Coffee {MEDIUM, DARK, DECAF }

Find the error(s) in the following switch statement and rewrite it correctly

// This code has errors!

Coffee mycup = DARK;

switch (myCup) {

  case Coffee.MEDIUM

     System.out.println("Mild flavor.");

     break;

  case Coffee.DARK :

     System.out.println("Strong flavor.");

     break;

  case Coffee.DECAF :

     system.out.println("Won't keep you awake.");

     break;

  default:

     System.out.println("Never heard of it.");

6. Short answer. Consider the following class declaration:

public class Thing {

  private int x;

  private int y;

  private static int z = 0;

  public Thing ( ) {

     x = z;

     y = z;

}

static void putThing( int a ) {

  z = a;

}

Assume a program containing the class declaration defines three Thing objects with the following statements:

Thing one= new Thing();

Thing two= new Thing();

Thing three= new Thing{);

a. How many separate instances of the x member exist?

b. How many separate instances of the y member exist?

c. How many separate instances of the z member exist?

d. What value will be stored in the x and y members of each object?

e. Write the statement that will call the putThing method.

7. A "has a" relationship can exist between classes. What does this mean?

8. This method converts a character to uppercase.

a. makeUpperCase

b. toUpperCase

c. isUpperCase

d. upperCase

9. This String class method performs the same operation as the + operator when used on strings.

a. add

b. join

c. concat

d. plus

10. True or False: If the toUppercase method's argument is already uppercase, it is returned as is, with no changes.

11. Find the error in each of the following code segments:

// Store a name in a StringBuilder object.

StringBuilder name = "Joe Schmoe";

12. Algorithm. Write loop that counts the number of lowercase characters that appear in the String object str.

13. Short Answer. Why should you use StringBuilder objects instead of String objects in a program that makes lots of changes to strings?

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question