Exposure C++ - Vernon Computer...

35
Exposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction This Test Is a KEY DO NOT WRITE ON THIS TEST This test includes program segments, which are not complete programs. Answer such questions with the assumption that the program segment is part of a correct program. 01. Class interaction is the process of (A) using classes in the established standard Java Language library. ### (B) using features from an existing class. (C) combining data and the methods, which process the data, inside the same module. (D) dividing a program into multiple related files for each class in the program. 02. The concept of inheritance is illustrated well with ### (A) geometry. (B) history. (C) literature. (D) economics. 03. The has-a relationship describes (A) inheritance. (B) encapsulation. (C) polymorphism. ### (D) composition. Exposure Java 2015, AP ® CS Edition Chapter 10 Test Page 1 06-02-15

Transcript of Exposure C++ - Vernon Computer...

Page 1: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

Exposure Java Multiple Choice TestChapter 10 Focus on OOP, Class Interaction

This Test Is a KEYDO NOT WRITE ON THIS TEST

This test includes program segments, which are not complete programs. Answer such questions with the assumption that the program segment is part of a correct program.

01. Class interaction is the process of

(A) using classes in the established standard Java Language library.### (B) using features from an existing class.

(C) combining data and the methods, which process the data, inside the same module.(D) dividing a program into multiple related files for each class in the program.

02. The concept of inheritance is illustrated well with

### (A) geometry.(B) history.(C) literature.(D) economics.

03. The has-a relationship describes

(A) inheritance.(B) encapsulation.(C) polymorphism.

### (D) composition.

04. The is-a relationship describes

### (A) inheritance.(B) encapsulation.(C) polymorphism.(D) composition.

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 1 06-02-15

Page 2: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

05. A class, which can use all the features of an established superclass is

(A) a static class.(B) a superclass.

### (C) a subclass.(D) an overloaded class.

06. An established class, whose members can be accessed by a newly declared class is

(A) a static class.### (B) a superclass.

(C) a subclass.(D) an overloaded class.

07. The engine, transmission, seats and other components required to make a car is an example of

(A) a superclass.(B) inheritance.(C) instantiation.

### (D) composition.

08. An offroad-truck, which is a special truck converted for off-roading with special shocks, mud tires and four-wheel drive is an example of

(A) a superclass.### (B) inheritance.

(C) instantiation.(D) composition.

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 2 06-02-15

Page 3: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

Consider the following program for questions 09 and 10.public class Test0910{ public static void main(String args[]) { Engine engine = new Engine(); Car car = new Car(); }}

class Engine{ public Engine() { System.out.println("Engine Constructor"); }}

class Car{ public Car() { System.out.println("Car Constructor"); }}

09. What is the class interaction between Car and Engine?

### (A) There is no class interaction(B) Inheritance(C) Composition(D) Improper class interaction

10. What is the output of Test0910?

### (A) Engine constructor (D) Car ConstructorCar constructor

(B) Car Constructor (E) Compile Error MessageEngine constructor

(C) Engine constructor (F) Runtime Exception Error Message

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 3 06-02-15

Page 4: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

Consider the following program for questions 11 and 12.public class Test1112{ public static void main(String args[]) { Car car = new Car(); }}

class Engine{ public Engine() { System.out.println("Engine Constructor"); }}

class Car{ private Engine engine; public Car() { engine = new Engine(); System.out.println("Car Constructor"); }}

11. What is the class interaction between Car and Engine?

(A) There is no class interaction(B) Inheritance

### (C) Composition(D) Improper class interaction

12. What is the output of Test101112?

### (A) Engine constructor (D) Car ConstructorCar constructor

(B) Car Constructor (E) Compile Error MessageEngine constructor

(C) Engine constructor (F) Runtime Exception Error Message

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 4 06-02-15

Page 5: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

Consider the following program for questions 13 and 14.public class Test1314{ public static void main(String args[]) { Car car = new Car(); }}

class Engine{ public Engine() { System.out.println("Engine Constructor"); }}

class Car extends Engine{ public Car() { System.out.println("Car Constructor"); }}

13. What is the class interaction between Car and Engine?

(A) There is no class interaction### (B) Inheritance

(C) Composition(D) Improper class interaction

14. What is the output of Test1314?

### (A) Engine constructor (D) Car ConstructorCar constructor

(B) Car Constructor (E) Compile Error MessageEngine constructor

(C) Engine constructor (F) Runtime Exception Error Message

Consider the following program for questions 15 and 16.Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 5 06-02-15

Page 6: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

public class Test1516{ public static void main(String args[]) { Car car = new Car(); }}

class Engine extends Car{ public Engine() { System.out.println("Engine Constructor"); }}

class Car { public Car() { System.out.println("Car Constructor"); }}

15. What is the class interaction between Car and Engine?

(A) There is no class interaction### (B) Inheritance

(C) Composition(D) Improper class interaction

16. What is the output of Test101516?

(A) Engine constructor ### (D) Car ConstructorCar constructor

(B) Car Constructor (E) Compile Error MessageEngine constructor

(C) Engine constructor (F) Runtime Exception Error Message

Consider the following program for questions 17 and 18.Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 6 06-02-15

Page 7: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

public class Test1718{ public static void main(String args[]) { Engine engine = new Engine(); }}

class Engine { private Car car; public Engine() { car = new Car(); System.out.println("Engine Constructor"); }}

class Car { public Car() { System.out.println("Car Constructor"); }}

17. What is the class interaction between Car and Engine?

(A) There is no class interaction(B) Inheritance

### (C) Composition(D) Improper class interaction

18. What is the output of Test101718?

(A) Engine constructor (D) Car ConstructorCar constructor

### (B) Car Constructor (E) Compile Error MessageEngine constructor

(C) Engine constructor (F) Runtime Exception Error Message

Consider the following program for questions 19 and 20.

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 7 06-02-15

Page 8: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

public class Test1920{ public static void main(String args[]) { Engine engine = new Engine(); }}

class Engine { private Car car; public Engine() { car = new Car(); System.out.println("Engine Constructor"); }}

class Car { private Engine engine; public Car() { engine = new Engine(); System.out.println("Car Constructor"); }}

19. What is the class interaction between Car and Engine?

(A) There is no class interaction(B) Inheritance(C) Composition

### (D) Improper class interaction

20. What is the output of Test1920?

(A) Engine constructor (D) Car ConstructorCar constructor

(B) Car Constructor (E) Compile Error MessageEngine constructor

(C) Engine constructor ### (F) Runtime Exception Error Message

Consider the following program for questions 21 and 22.Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 8 06-02-15

Page 9: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

public class Test2122{ public static void main(String args[]) { Car car = new Car(); Engine engine = new Engine(); }}

class Engine extends Car { public Engine() { System.out.println("Engine Constructor"); }}

class Car extends Engine { public Car() { System.out.println("Car Constructor"); }}

21. What is the class interaction between Car and Engine?

(A) There is no class interaction(B) Inheritance(C) Composition

### (D) Improper class interaction

22. What is the output of Test1022?

(A) Engine constructor (D) Car ConstructorCar constructor

(B) Car Constructor ### (E) Compile Error MessageEngine constructor

(C) Engine constructor (F) Runtime Exception Error Message

23. What is the output of the following program?

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 9 06-02-15

Page 10: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

public class Test1023

{

public static void main(String[] args)

{

Point point = new Point(500,300);

System.out.println("Point at (" + point.getX() + "," + point.getY() + ")");

}

}

class Point

{

private int x;

private int y;

public Point(int x, int y)

{

this.x = x;

this.y = y;

}

public int getX() { return x; }

public int getY() { return y; }

}

(A) Point at (0,0)

### (B) Point at (500,300)

(C) Point at (300, 500)

(D) Point (X,Y) at (0,0)

24. What is the output of the following program?Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 10 06-02-15

Page 11: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

public class Test1024

{

public static void main(String[] args)

{

Point point = new Point(500,300);

System.out.println("Point at (" + point.getX() + "," + point.getY() + ")");

}

}

class Point

{

private int x;

private int y;

public Point(int x, int y)

{

x = x;

y = y;

}

public int getX() { return x; }

public int getY() { return y; }

}

### (A) Point at (0,0)

(B) Point at (500,300)

(C) Point at (300, 500)

(D) Point (X,Y) at (0,0)

25. Consider the following program output of a tree,

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 11 06-02-15

Page 12: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

shown in chapter X about class interaction.The program uses the Point, TreeTrunk, Leavesand Tree classes.

What is the class interaction between those classes?

(A) Inheritance only### (B) Composition only

(C) Both inheritance and composition(D) There is no class interaction

26. Consider the following program output of a pine tree,shown in chapter X about class interaction.The program uses the Point, Trunk, LeavesTree and PineTree classes.

What is the class interaction between those classes?

(A) Inheritance only(B) Composition only

### (C) Both inheritance and composition(D) There is no class interaction

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 12 06-02-15

Page 13: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

27. What types of methods can be found in a subclass?

(A) No methods at all. The subclass can an empty class declaration.(B) Re-defined methods(C) Newly-defined method

### (D) All of the above

28. What is the consequence of declaring and using a totally empty class body in a program?

(A) The subclass will not compile.(B) The subclass will has a a runtime exception during program execution.

### (C) The subclass will behave exactly like the superclass.(D) The subclass will compile and execute, but have no output.

Consider the ChristmasTree output for questions 29 and 30.

29. Consider the following program output of a Christmas Tree, shown in chapter X about class interaction.The program uses the Point, Trunk, LeavesTree, PineTree and XmasTree classes.

What is the class interaction between those classes?

(A) Inheritance only(B) Composition only

### (C) Both inheritance and composition(D) There is no class interaction

30. The drawOrnaments method in the XmasTree class is

(A) first defined in the PineTree class.(B) re-defined for the XmasTree class.(C) first defined in the Tree class.

### (D) newly-defined in the XmasTree class.

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 13 06-02-15

Page 14: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

Consider the Jack-O'-Lantern output for questions 31, 32 and 33.

31. Consider the following program output of a Jack-O'Lantern. The program is created with the interaction of a Pumpkin class, Face class and a JackOLantern class.

What is the class interaction between those three classes?

(A) Inheritance only(B) Composition only

### (C) Both inheritance and composition(D) There is no class interaction

32. What is the class interaction between the Pumpkin class and the Face class?

(A) Inheritance only### (B) Composition only

(C) Both inheritance and composition(D) There is no class interaction

33. What is the class interaction between the Pumpkin class and the JackOLantern class?

### (A) Inheritance only(B) Composition only(C) Both inheritance and composition(D) There is no class interaction

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 14 06-02-15

Page 15: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

Consider the Choo-choo Train output for questions 34, 35 and 36.

34. Consider the following program output of a Train. The program is created with the interaction of a TrainCar class, Locomotive class, Caboose class and a Train class.

What is the class interaction between those four classes?

(A) Inheritance only(B) Composition only

### (C) Both inheritance and composition(D) There is no class interaction

35. The program output shows five traincars. This means that a Locomotive

(A) has-a Caboose.(B) is-a Train.

### (C) is-a TrainCar.(D) has-a TrainCar.

36. Composition is used between which of the following classes?

(A) Train and Caboose(B) Train and Locomotive(C) Train and TrainCar

### (D) All of the above

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 15 06-02-15

Page 16: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

37. Consider the following class heading.

public class Person extends Student

What is not true about the class interaction of that class heading?

(A) It indicates an "is-a" class interaction between the two classes.(B) It indicates an inheritance relationship between Person and Student

### (C) It indicates that Person is the superclass and Student is the subclass.(D) It indicates that Student is the superclass and Person is the subclass.

38. A Square is-a Rhombus and a Square is-a Rectangle.In computer science this type of class-interaction is called

(A) Multi-level inheritance### (B) Multiple inheritance

(C) Complex inheritance(D) Double inheritance

39. Which of the following Java class headings declares Square a subclass with multiple inheritance?

(A) public class Square extends Rhombus & Rectangle(B) public class Square Rhombus, Square(C) Public class Square extends (Rhombus, Rectangle)(D) public class Square extends both Rhombus, Rectangle

### (E) Java does not support multiple inheritance.

40. A Dog is-a Mammal and a Mammal is-an Animal.In computer science this type of class-interaction is called

### (A) Multi-level inheritance(B) Multiple inheritance(C) Complex inheritance(D) Double inheritance

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 16 06-02-15

Page 17: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

Consider the following program for questions 41 and 42.public class Test4142{ public static void main(String args[]) { Student tom = new Student(); System.out.println("tom's age is " + tom.getAge()); System.out.println("tom's grade is " + tom.getGrade()); }}

class Person{ private int age;

public int getAge() { return age; }}

class Student extends Person{ private int grade;

public int getGrade() { return grade; }}

41. What evidence exists that proves that inheritance is functional in this program?

(A) The Student class extends the Person class.(B) The tom object has access to the getGrade method.

### (C) The tom object has access to the getAge method.(D) There is evidence of class interaction with composition, but not with inheritance.

42. What is the consequence of removing extends Person from the program above?

(A) The class interaction will change from inheritance to composition.(B) The class interaction will change from composition to inheritance.(C) The program will compile, but it will not execute correctly.

### (D) There will no longer compile, since the getAge method is not acessible.

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 17 06-02-15

Page 18: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

Use this program for questions 43 & 44.public class Test4344{ public static void main(String args[]) { Student tom = new Student(12); tom.showData(); }}

class Person{ public int age;

public Person() { System.out.println("Person Parameter Constructor"); age = 17; }

public int getAge() { return age; }}

class Student extends Person{ public int grade;

public Student(int g) { grade = g; System.out.println("Student Parameter Constructor"); }

public int getGrade() { return grade; }

public void showData() { System.out.println("Student's Grade is " + grade); System.out.println("Student's Age is " + age); }}

43. What are the first 2 lines of output?

### (A) Person Parameter ConstructorStudent Parameter Constructor

(B) Student Parameter ConstructorPerson Parameter Constructor

(C) Person Parameter ConstructorPerson Parameter Constructor

(D) Student Parameter ConstructorStudent Parameter Constructor

(E) No Output.This program does not compile.

44. What are the last 2 lines of output?

### (A) Student's Grade is 12Student's Age is 17

(B) Student's Grade is 12Student's Age is 17

(C) Student's Grade is 12Student's Age is 17

(D) Student's Grade is 12Student's Age is 17

(E) No Output.This program does not compile.

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 18 06-02-15

Page 19: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

45. The Object class

(A) must be individually extended for any class.### (B) is the super class for any Java class.

(C) is the super class for any standard Java class only.(D) is the super class for any user-defined Java class only.(E) used only with primitive data types.

46. Use of Object class methods

(A) is possible only with the used of extends.(B) is possible only by including import java.util.Object in your program.

### (C) is automatically available in any class.(D) is restricted to primitive data types only.(E) requires re-definition of the Object methods.

47. Object methods

(A) behave the same for all classes.(B) behave only according to the definitions in Object subclasses.

### (C) follow the definitions originated in the Object class, unless re-defined.(D) are available to classes of the java.util.* package only.

48. Methods toString and equals are

(A) first defined in the String class.(B) first defined in the Object class.(C) re-defined in the String class.(D) re-defined in the Object class.

### (E) both B and C.

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 19 06-02-15

Page 20: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

49. Which class or classes have access to the toString method?

(A) The String class only

(B) The Object class only

(C) Any Java standard library class only

(D) Any user-defined class only

### (E) Any Java standards library class or user-defined class.

50. Imagine that you must define a Person class. Which of the following Person class headingsmust be incorrect?

(A) public class Person

(B) public class Person extends Object

(C) public class Person extends ArrayList

(D) class Person

### (E) All of the above Person class headings can be correct.

51. Method toString

(A) must be included in any user-defined class.

(B) is only used by the String class.

### (C) is first defined in the Object class.

(D) converts any object to a String object.

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 20 06-02-15

Page 21: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

52. What is the output of this program?

public class Question1052{

public static void main (String args[ ]){

Student student1 = new Student("Jessica Schram",17,3.99);Student student2 = new Student("John Smith",18,1.21);System.out.println(student1);System.out.println(student2);

}}

class Student{

private String name;private int age;private double gpa;

public Student(String n, int a, double g){

name = n;age = a;gpa = g;

}

public String toString(){

return name;}

}

(A) [Jessica Schram, 17, 3.99][John Smith, 18, 1.21]

(B) Jessica SchramJessica Schram

### (C) Jessica SchramJohn Smith

(D) 2 memory addresses

(E) Error

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 21 06-02-15

Page 22: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

53. What is the output of this program?

public class Java1053{

public static void main (String args[ ]){

Student student1 = new Student("Jessica Schram",17,3.99);Student student2 = new Student("John Smith",18,1.21);System.out.println(student1);System.out.println(student2);

}}

class Student{

private String name;private int age;private double gpa;

public Student(String n, int a, double g){

name = n;age = a;gpa = g;

}}

(A) [Jessica Schram, 17, 3.99][John Smith, 18, 1.21]

(B) Jessica SchramJessica Schram

(C) Jessica SchramJohn Smith

### (D) Student@d457f9 (or other memory address)Student@06be2a (or other memory address)

(E) Error

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 22 06-02-15

Page 23: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

54. What is the output of this program?

public class Java1054{

public static void main (String args[ ]){

Student student1 = new Student("Jessica Schram",17,3.99);Student student2 = new Student("John Smith",18,1.21);System.out.println(student1);System.out.println(student2);

}}

class Student{

private String name;private int age;private double gpa;

public Student(String n, int a, double g){

name = n;age = a;gpa = g;

}

public String toString(){

return "[" + name + ", " + age + ", " + gpa + "]";}

}

### (A) [Jessica Schram, 17, 3.99][John Smith, 18, 1.21]

(B) Jessica SchramJessica Schram

(C) Jessica SchramJohn Smith

(D) Student@d457f9 (or other memory address)Student@06be2a (or other memory address)

(E) Error

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 23 06-02-15

Page 24: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

55. What is the output of this program?

public class Java1055{

public static void main (String args[]){

Student student1 = new Student("Jessica Schram",17,3.99);Student student2 = new Student("John Smith",18,1.21);System.out.println(student1);System.out.println(student2);

}}

class Student{

private String name;private int age;private double gpa;

public Student(String n, int a, double g){

name = n;age = a;gpa = g;

}

public String toString(){

return "Jessica Schram";}

}

(A) [Jessica Schram, 17, 3.99][John Smith, 18, 1.21]

### (B) Jessica SchramJessica Schram

(C) Jessica SchramJohn Smith

(D) Student@d457f9 (or other memory address)Student@06be2a (or other memory address)

(E) Error

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 24 06-02-15

Page 25: Exposure C++ - Vernon Computer Sciencevernonmath.com/wp/wp-content/uploads/2016/01/Test10Key.d… · Web viewExposure Java Multiple Choice Test Chapter 10 Focus on OOP, Class Interaction

56. What criteria is used by the == operator to test for equality?

(A) It compares values that were assigned to the variables during program execution.### (B) It compares the shallow values only.

(C) It compares the deep values only.(D) It compares both the shallow values and the deep values.

57. The equals method, as defined by the Object class

(A) compares values that were assigned to the variables during program execution.### (B) compares shallow values only.

(C) compares deep values only.(D) compares both shallow values and deep values

58. Which of the following standard Java classes has redefined the equals method?

### (A) String(B) Object(C) System(D) Math(E) Both A & B

59. If a class has three attributes, age, name and gender, then redefining the equals method

(A) requires that at most one of the attributes is compared for equality.(B) requires that all three of the attributes are compared for equality.(C) requires that one or more of the attributes is compared for equality.

### (D) does not require that any of the attributes are compared for equality.

60. Which of the following is an example of a Utility class?

### (A) The Math class(B) A Truck class that extends a car class.(C) A Car class which has an attribute that is an object of the Engine class.(D) A TireSwing class which extends the Swing class and contains a Tire object.

Exposure Java 2015, AP®CS Edition Chapter 10 Test Page 25 06-02-15