AP Java Ch. 4 Review
Question 1 Java methods can return only primitive types (int, double, boolean, etc).
Question 2 All Java classes must contain a main method which is the first method executed when the Java class is called upon.
Question 3 Java methods can return more than one item if they are modified with the reserved word continue, as in public continue int foo( ) { … }
Question 4 The following method header definition will result in a syntax error: public void aMethod( );
Question 5 A method defined in a class can access the class’ instance data without needing to pass them as parameters or declare them as local variables.
Question 6 The interface of a class is based on those data instances and methods that are declared public.
Question 7 Defining formal parameters requires including each parameters type.
Question 8 Every class definition must include a constructor.
Question 9 While multiple objects of the same class can exist, there is only one version of the class.
Question 10 A constructor must always return an int.
Question 11 A class’s instance data are the variables declared in the main method.
Question 12 The return statement must be followed a single variable that contains the value to be returned.
Question 13 A method defined without a return statement will cause a compile error.
Question 14 The println method on System.out is overloaded.
Question 15 Method decomposition is the process of creating overloaded versions of a method that do the same thing, but operate on different data types.
Question 16 An object may be made up of other objects.
Question 17 In a method with both a precondition and a postcondition, the postcondition should be true when the method finishes executing regardless of whether the precondition was true.
Question 18 An accessor method provides access to a value and allows the caller to change that value.