Professional Documents
Culture Documents
. g good
program
ming
guideline
s, what
access
modifier
should
be used
for the
class
fields in
the
following
situation
?
A car
insuranc
e
company
wants to
create a
class
named
Custome
r that
stores all
data for
a
specified
custome
r
including
the
fields:
vehicle
informati
on,
policy
informati
on, and
a credit
card
number.
Public
Protected
Private (*)
Default
All of the above
Correct
2. A team is working on a coding project. They desire that all portions of their
code should have access to the classes that they write. What access
modifier should be used for each class?
Mark for
Review
(1) Points
Public (*)
Protected
Private
Default
All of the above
Correct
3. Which of the following could be a reason to need to pass an object into a
method?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
int DolphinTalk(dol1, dol2){ if(dol1 > dol2) return dol1; else return
dol2;}
int DolphinTalk(int,int){ if(dol1 > dol2) return dol1; else return dol2;}
int DolphinTalk(int dol1,int dol2){ if(dol1 > dol2) return dol1; else return
dol2;} (*)
int DolphinTalk, int dol1,int dol2 { if(dol1 > dol2) return dol1; else
return dol2;}
All of the above
Correct
5. Cameron wishes to write a method that takes in two objects and returns
the one with the greatest value. Is this possible?
Mark for
Review
(1) Points
Yes, but he will have to use two different methods, one to take in the
objects and the other to return an object.
Yes, methods can take objects in as parameters and can also return
objects all within the same method. (*)
No, it is not possible to return objects.
No, it is not possible to have objects as parameters or to return objects.
Correct
6. You are assigned to write a method that compares two objects of type
Career. One requirement of your assignment is to have your method
compare the "greatestPossibleSalary" instance data of Career objects. The
"greatestPossibleSalary" field is data type int.
What would be the best return type from your compare method?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
9. It is possible to have more than one constructor with the same name in a
class, but they must have different parameters. True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
10. Which of the following is a possible way to overload constructors?
Mark for
Review
(1) Points
(*)
Correct
11. It is possible to overload a method that is not a constructor. True or False?
Mark for
Review
(1) Points
True (*)
False
Correct
12. Identify the error(s) in the class below. Choose all that apply.
Mark for
Review
(1) Points