CS180 REVISION STUDY EXAM QUESTIONS
AND ANSWERS UNIVERSITY OF CALIFORNIA
What does the following UML diagram entry mean?
+ setHeight (h : double) : void
a) a public method with a parameter of data type double that does not
return a value
b) a private field called setHeight that is a double data type
c) a private method with no parameters that returns a double data type
d) public field called setHeight that is a double data type
Verified Answer -a public method with a parameter of data type double
that does not return a value
A class specifies the ____ and ____ for a particular type of object.
a) relationships, ,methods
b) fields, object names
c) fields, methods
d) relationships, object names
Verified Answer -fields, methods
It is common practice in object-oriented programming to make all of a
class's ____.
a) fields private
b) methods private
c) fields public
,d) fields and methods public
Verified Answer -fields private
For the following code, which statement is not true?
public class Sphere
{
private double radius;
public double x;
private double y;
private double z;
}
a) The z field is available to code written outside the Sphere class.
b) The radius field is not available to code written outside the Sphere class.
c) The radius, x, y, and z fields are members of the Sphere class.
d) The x field is available to code that is written outside the Sphere class.
Verified Answer -The z field is available to code written outside the Sphere
class.
One or more objects may be created from a(n) ____.
a) field
b) method
c) instance
d) class
Verified Answer -class
, You should not store calculated data, such as a Rectangle object's area, in
a field because it is dependent on the current data stored in other fields.
Instead, it should be recalculated each time this data is needed to avoid
____.
a) confusion
b) redundancy
c) stale data
d) none of these
Verified Answer -stale data
When a primitive type variable is passed as an argument to a method,
what is passed into the receiving method's parameter variable?
a) a copy of the value stored in the variable
b) the object's memory address
c) neither of these
d) both of these
Verified Answer -a copy of the value stored in the variable
When an object type variable is passed as an argument to a method, what
is passed into the receiving method's parameter variable?
a) a copy of the value stored in the variable
b) the object's memory address
c) neither of these
d) both of these
Verified Answer -the object's memory address
Data hiding means that critical data stored inside the object is protected
from code outside the object. This is accomplished in Java by ____.
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller AcademicAllure. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $15.49. You're not tied to anything after your purchase.