Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

puolclass Student :1; Word . Ist DignLayou: Rfeen Miings ReveTelme what you wan

ID: 3606486 • Letter: P

Question

puolclass Student :1; Word . Ist DignLayou: Rfeen Miings ReveTelme what you wan to do Cul pboard Farzgzph Shles Toleep uangyourGfficepistons uttain imemipen, plesse reev br srday, November 5, 2117, Ouy 6) The relationship oetween class and n otiectbest described as AI classes re instances of obscB) oolccts re instaces of classes Clobjects and clascs are thesamthing Dclareprograms while objects are vonales E> objectare the intance dat of dusses RENOW YOUk SUBSCRIPTION Navigation uurch doeumnt Headings P Rls Creaie an iici o.ine fyuu 7) To define cles that wil represent a car, which ofte folowing cern tions most approprite? Al prate dass car El publc clacs car Cputli: class CrD)pubic c CAR E)prtvate clacs Car Ta get etartea, go so the Home tab and apply 2) which of the folowing reserved worcds in av used to create an Into AI class B1 Rublie public or private, cither could be used D' import E) new class? 9) in order to preserve encapulatin of an objet,w uld do all of the folcwing exc or which onc? Al Make the Instanc dato privatc BI Define the methods in thelass to ccess and manipulate the instance dota C) M ke the mgthods of the cass public D) M ke the class final E> All of the ddve preserve encapsulation c) If a method docs not he a return starement,the AI it wil produce srtax emor when compilad e) it must be a void method C) t annot be called fromutside the class that cerned the method it must be defined to e public method E)It must be n t dcuble, float or String method 11) A varlable whos scope srestricted to the method where it wa: declared is ka asn Al parceter Bglotal varnatle C) lcl varlabic D) public Instance data El pnvate instac cata 12) Acconstructer uualy defines AI hcw n object is initialized BI howan cb ectInter cod Cl te number of instance data n the class D tna number of methods in the clos E If the rstance data ar accsble autside of the cbject directly E O lype here to search

Explanation / Answer

7)

public class Car

Classes should be defined to be public so that they can be accessed by other classes. And
following Java naming convention, class names should start with a capital letter and be lower case except for the
beginning of each new word, so Car is more appropriate than car or CAR.

8)

e) new

The reserved word "new" is used to instantiate an object, that is, to create an instance of a
class. The statement new is followed by the name of the class. This calls the class' constructor. Example: Car x = new
Car( ); will create a new instance of a Car and set the variable x to it.

9)

d) Make the class final

10)

b) it must be a void method

All methods are implied to return something and therefore there must be a return statement.
However, if the programmer wishes to write a method that does not return anything, and therefore does not need a
return statement, then it must be a void method (a method whose header has "void" as its return type).

11)

c) local variable

12)

a) how an object is initialized

The constructor should be used to "construct" the object, that is, to set up the initial values of
the instance data. This is not essential, but is typically done. The interface of an object is dictated by the visibility
modifiers used on the instance data and methods.