97%(230)222 out of 230 people found this document helpful
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. class16.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, 8eSolutions 10-419.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 Exercises1.Identify three objects that might belong to each of the following classes:a.Buildingb.Artistc.BankLoan2.Identify three different classes that might contain each of these objects:a.William Shakespeareb.My favorite red sweater
Programming Logic and Design, 8eSolutions 10-5c.Public School 23 in New York CityAnswer: A sample solution followsThe answers to this question will also vary. Some examples are:a.Person, Englishman, Playwrightb.CashmereItem, RedThing, Clothingc.Building, School, Location3.Design a class named TermPaperthat 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 followsDiagram:TermPaper-authorName: string-subject: string-letterGrade: string+setAuthorName(name : string) : void+setSubject(sub : string) : void+setLetterGrade(grade : string) : void+displayValues() : voidPseudocode:class TermPaperDeclarationsprivate string authorNameprivate string subjectprivate string letterGradepublic void setAuthorName(string name)authorName = namereturnpublic void setSubject(string sub)subject = subreturnpublic void setLetterGrade(string grade)letterGrade = gradereturnpublic void displayValues()output “Author name: ”, authorName