Question: 1.Reference-type variables (called references) store _____ in memory. the value of an object a copy of an object the memory location of an object the

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

the value of an object
a copy of an object
the memory location of an object
the size of an object

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

the house.
the blueprint.
neither
both

3. Set methods are also commonly called _____ methods.

query
accessor
mutator
static

4.Which of the following statements is false?

By convention class names begin with an uppercase letter, and method and variable names begin with a lowercase letter.
Instance variables exist before methods are called on an object, while the methods are executing and after the methods complete execution.
A class normally contains one or more methods that manipulate the instance variables that belong to particular objects of the class.
Private instance variables are directly accessible outside of the class that contains them.

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();

myGrades.calcAvg();
calcAvg.Grades();
Grades.calcAvg();
calcAvg.myGrades();

6. A key part of enabling the JVM to locate and call method main to begin the apps 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.

class
private
static
public

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

to the left of the decimal point
centered
to the right of the decimal point
None of the above

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 } }

n = num;
this.n = num;
num = n;
num = 0;

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();

The variable num must have an initial value.
The Scanner object must be created before num is declared.
The method nextInt must be used instead of nextLine.
This code is correct as is.

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; } }

0
5
6
7

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!