

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


This quiz is to be taken by yourself with closed books, closed notes, no electronic devices.
Matching:
_____ Field/Data in an object
_____ Messages sent to objects
_____ A way to create a new object
_____ Code to initialize a newly created object
_____ Must be the same name as the class name
_____ Refers to the object being sent a message inside a method
_____ Must have a return type in its header
_____ If uninitialized, has no default value (garbage)
_____ Must not have a return type as part of its header
_____ Return type for accessors/getters
_____ Can only be accessed by its simple name, no reference qualifier
_____ By Java naming convention, starts with an uppercase letter
_____ A sometimes "better" return type for mutators/setters
_____ Methods or constructors that have the same name but differ in the number, type, or order of parameters
_____ Most instance variables should be this access mode
_____ Most methods and constructors should be this access mode
A) private B) instance method C) class / class name D) boolean E) instance variable F) new operator G) this H) static variable I) Object J) void K) type of the instance variable accessed L) constructor M) overload N) public O) local variable
[You do not need to use all letters. Some letters will need to be used more than once.]
Assume there is a class named Student with an instance variable defined as
String name;
Write the mutator/setter method for the instance variable name above. Assume no return value or data checks.
____________ ______________________( String name ) { __________________ = __________________ ; }
Will the following code compile? ___________ (Yes or No) If not, what change do you need to make to the method header (not the body) so that it will compile? Explain. Be specific.
public int test( double x ) { if ( x ) { System.out.println( "In test" ); } return 42; }
Will the following code compile? ___________ (Yes or No) If not, what change do you need to make to the method header (not the body) so that it will compile? Explain. Be specific.
public void test( double x ) { System.out.println( "In test" ); return x + x; }
What question(s) would you like to see on the Final Exam?