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

1.Reference-type variables (called references) store _____ in memory. 2. A contr

ID: 3855267 • Letter: 1

Question

1.Reference-type variables (called references) store _____ in memory.

2. A contractor uses a blueprint to build a house. An object is similar to

3. Set methods are also commonly called _____ methods.

4.Which of the following statements is false?

5.A class named Grades has a public method named calcAvg. Which statement is valid regarding an instance of that class that is created as
            Grades myGrades = new Grades();

6. A key part of enabling the JVM to locate and call method main to begin the app’s execution is the _____ keyword, which indicates that main can be called without first creating an object of the class in which the method is declared.

7. The format specifier %.2f specifies that two digits of precision should be output _____ in the floating-point number.

8. Which statement is correct to complete the setNum method below?

public class Test
{
         private int num;
         public void setNum(int n)
         {
                  //what goes here
         }
}

9. What error, if any, is in the following code?

int num;
Scanner input = new Scanner(System.in);
System.out.print(“Enter a number: ”);
num = input.nextLine();

10. What does the following code display?

public class RentalApp {

         public static void main(String[] args)
         {
                  Rental r = new Rental();
                  r.setNumOfPersons(5);
                  r.addPerson();
                  r.addPerson();
                  System.out.println(r.getNumOfPersons());
         }
}

public class Rental
{
         private int numOfPersons;

         public int getNumOfPersons()
         {
                  return numOfPersons;
         }

         public void setNumOfPersons(int numOfPersons)
         {
                  this.numOfPersons = numOfPersons;
         }

         public void addPerson()
         {
                  numOfPersons = numOfPersons + 1;
         }
}

the value of an object

Explanation / Answer

1) the memory location of an object

2) the house

3) mutator

4) Private instance variables are directly accessible outside of the class that contains them.

5) myGrades.calcAvg();

6) static

7) to the right of the decimal point

8) num = n;

9) The method nextInt must be used instead of nextLine.

10) 7