A static method is also known as an method a instance b public c private d

A static method is also known as an method a instance

This preview shows page 3 - 6 out of 31 pages.

15.A static method is also known as a(n) __________ method. a. instanceb. publicc. privated. class 16.By default, methods contained in a class are __________ methods. 17.Assume that you have created a class named MyClass, and that a working program contains the following statement:output MyClass.numberWhich of the following do you know? 18.Assume that you have created an object named myObjectand that a working program contains the following statement:output myObject.getSize()Which of the following do you know?
Programming Logic and Design, 8e Solutions 10-4 19.Assume that you have created a class that contains a private field named myFieldand a nonstatic public method named myMethod(). Which of the following is true? a. myMethod()has access to and can use myFieldb. myMethod()does not have access to and cannot use myFieldc. myMethod()can use myFieldbut cannot pass it to other methods.d. myMethod()can use myFieldonly if myFieldis passed to myMethod()parameter. . . as a 20.An object can be __________. Programming Exercises 1.Identify three objects that might belong to each of the following classes:a.Buildingb.Artistc.BankLoan 2.Identify three different classes that might contain each of these objects:a.William Shakespeareb.My favorite red sweater
Programming Logic and Design, 8e Solutions 10-5 c. Public School 23 in New York City Answer: A sample solution follows The answers to this question will also vary. Some examples are: a. Person, Englishman, Playwright b. CashmereItem, RedThing, Clothing c. Building, School, Location 3. Design a class named TermPaper that holds an author’s name, the subject of the paper, and an assigned letter grade. Include methods to set the values for each data field and display the values for each data field. Create the class diagram and write the pseudocode that defines the class. Answer: A sample solution follows Diagram: TermPaper -authorName: string -subject: string -letterGrade: string +setAuthorName(name : string) : void +setSubject(sub : string) : void +setLetterGrade(grade : string) : void +displayValues() : void Pseudocode: class TermPaper Declarations private string authorName private string subject private string letterGrade public void setAuthorName(string name) authorName = name return public void setSubject(string sub) subject = sub return public void setLetterGrade(string grade) letterGrade = grade return public void displayValues() output “Author name: ”, authorName

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture