nerd stuff 5

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Consider the following code snippet: Coin coin1 = null; System.out.println("Value of coin = " + coin1.getValue()); What is wrong with this code? a) coin1 does not refer to an object and will result in an error at run time. b) You cannot concatenate a numeric value with a string value. c) The value variable in coin1 has not been set, and will print as 0. d) There is nothing wrong with this code.

a

Which operator should you use to test whether an object reference is null? a) == b) >= c) <= d) =

a

Which of the following declares a rpmRating instance variable for a Motor class that stores an integer value? a) private integer rpmRating; b) private int rpmRating; c) public integer rpmRating; d) public int rpmRating;

b

Which choice indicates that a string variable refers to no string? a) nil b) "" c) null d) empty

c

Which of the following statements about classes is correct? a) When programmers work with an object of a class, they do not need to know how the object stores its data or how its methods are implemented. b) When programmers work with an object of a class, they must understand how the object stores its data and how its methods are implemented. c) When programmers work with an object of a class, they must understand only how the object stores its data. b) When programmers work with an object of a class, they must understand only how the object's methods are implemented

a

Which of the following statements is true regarding classes? a) Each object of a class has a separate copy of each instance variable. b) All objects created from a class share a single set of instance variables. c) Private instance variables can be accessed by any user of the object. d) Public instance variables can be accessed only by the object itself.

a

Which statement calls a constructor with no construction parameters? a) Circle c = new Circle(); b) Circle c = new Circle; c) Circle c = Circle() d) A call to a constructor must have construction parameters

a

You have created a Motorcycle class which has a constructor with no parameters. Which of the following statements will construct an object of this class? a) Motorcycle myBike; b) Motorcycle myBike = new Motorcycle(); c) myBike.new(Motorcycle); d) Motorcycle.new(myBike);

a

You have created a Student class. You wish to have a unique, sequential student number assigned to each new Student object that is created. Which of the following declarations, if added to the Student class, would allow you to determine which number was last assigned when you are creating a new Student object? a) private static int lastAssignedStudentNum = 1500; b) public int lastAssignedStudentNum = 1500; c) private int lastAssignedStudentNum = 1500; d) public static int lastAssignedStudentNum = 1500;

a

You have created an Employee class. You wish to have a unique, sequential employee number assigned to each new Employee object that is created. Which of the following declarations, if added to the Employee class, would allow you to determine which number was last assigned when you are creating a new Employee object? a) private static int lastAssignedEmpNum = 500; b) public int lastAssignedEmpNum = 500; c) private int lastAssignedEmpNum = 500; d) public static int lastAssignedEmpNum = 500;

a

A method in a class that returns information about an object but does not change the object is called a/an ____ method

accessor

Which of the following are considered members of a class?

all instance variable and methods

37) Private instance variables ___. a) can only be accessed by methods of a different class b) can only be accessed by methods of the same class c) cannot be accessed by methods of the same class d) can only be accessed by the constructor of the class

b

An instance variable declaration consists of ____. a) the return type, the name of the method, and a list of the parameters (if any). b) an access specifier, the type of the instance variable, and the name of the instance variable. c) an access specifier, a list of the parameters (if any), and the body of the method. d) the type of the instance variable, an access specifier, a list of the parameters (if any), and the body of the method

b

Consider the following code snippet: public class AutoRace { private int lapCount; private double totalTime; . . . } Which of the following completeLap methods would correctly track how many laps occurred? a) public void completeLap(double lapTime) { totalTime = totalTime + lapTime; } b) public void completeLap(double lapTime) { totalTime = totalTime + lapTime; lapCount ++; } c) public void completeLap(double lapTime) { totalTime = totalTime + lapTime; lapCount = lapCount + lapTime; } d) public void completeLap(double lapTime) { totalTime = lapCount + lapTime; }

b

Consider the following code snippet: public class BankAccount { private int transactionCount; private double balance; . . . } Which of the following deposit methods would correctly track how many deposits occurred? a) public void deposit(double amount) { balance = balance + amount; } b) public void deposit(double amount) { balance = balance + amount; transactionCount ++; } c) public void deposit(double amount) { balance = balance + amount; transactionCount = transactionCount + amount; } d) public void deposit(double amount) { balance = transactionCount + amount; }

b

Consider the following code snippet: public class Coin { . . . public void setCoinName(String name) {. . . } public String getCoinName() {. . . } public String getCoinValue() {. . . } } Assuming that the names of the methods reflect their action, which of the following statements about this class is correct? a) setCoinName is an accessor method. b) setCoinName is a mutator method. c) getCoinName is a mutator method. d) getCoinValue is a mutator method.

b

Consider the following code snippet: public class Coin { private String coinName; . . . } Which of the following statements is correct? a) The coinName variable can be accessed by any user of a Coin object. b) The coinName variable can be accessed only by methods of the Coin class. c) The coinName variable can be accessed only by methods of another class. d) The coinName variable cannot be accessed at all because it is private

b

Consider the following code snippet: public class Course { private int studentCount; . . . } Which of the following methods would correctly keep track of the total number of enrollees in a course? a) public void addEnrollees(int newEnrollees) { studentCount = newEnrollees } b) public void addEnrollees(int newEnrollees) { studentCount = studentCount + newEnrollees } c) public void addEnrollees(int newEnrollees) { newEnrollees = studentCount } d) public void addEnrollees(int newEnrollees) { newEnrollees = newEnrollees + studentCount }

b

Consider the following code snippet: public class Employee { private String empName; . . . } Which of the following statements is correct? a) The empName variable can be accessed by any user of an Employee object. b) The empName variable can be accessed only by methods of the Employee class. c) The empName variable can be accessed only by methods of another class. d) The empName variable cannot be accessed at all because it is private.

b

Consider the following code snippet: public class Student { private static int lastAssignedStudentNum = 1500; { . . . } } Which of the following statements about this code is correct? a) Each object created from this class will have its own lastAssignedStudentNum variable. b) All objects created from this class will share the lastAssignedStudentNum variable. c) The lastAssignedStudentNum variable's value cannot be changed. d) You cannot assign a value to a static variable.

b

Consider the following code snippet: public class Transaction { private int transactionCount; . . . } Which of the following methods would correctly keep track of the total number of transactions? a) public void addTransactions(int newTransactions) { transactionCount = newTransactions } b) public void addTransactions(int newTransactions) { transactionCount = transactionCount + newTransactions } c) public void addTransactions(int newTransactions) { newTransactions = transactionCount } d) public void addTransactions(int newTransactions) { newTransactions = newTransactions + transactionCount }

b

Consider the following code snippet: public class Vehicle { . . . public void setVehicleAttributes(String attributes) {. . . } public String getVehicleAtrributes() {. . . } public String getModelName() {. . . } } Assuming that the names of the methods reflect their action, which of the following statements about this class is correct? a) setVehicleAttributes is an accessor method. b) setVehicleAttributes is a mutator method. c) getVehicleAttributes is a mutator method. d) getModelName is a mutator method.

b

Consider the following code snippet: public int getCoinValue(String coinName) { . . . } Which of the following statements is correct? a) coinName is an implicit parameter. b) coinName is an explicit parameter. c) coinName is the object on which this method is invoked. d) coinName is an instance variable.

b

Consider the following code snippet: public int getSalary(String empNum) { . . . } Which of the following statements is correct? a) empNum is an implicit parameter. b) empNum is an explicit parameter. c) empNum is the object on which this method is invoked. d) empNum is an instance variable.

b

If you do not provide a constructor in a class, which of the following is correct? a) The compiler will generate a constructor with arguments for each class instance variable and will initialize all of the class instance variables. b) The compiler will generate a constructor with no arguments. c) The compiler will generate a constructor with arguments for each class instance variable. d) The class code will not compile

b

Insert the missing code in the following code fragment. This fragment is intended to implement a method to set the state of the object. public class Motor { public static final STOPPED = 0; public static final PAUSED = 1; public static final RUNNING = 2; private int motorState; . . . public void stopMotor() { ________ } } a) motorState++; b) motorState = STOPPED; c) motorState = PAUSED; d) motorState = RUNNING

b

Insert the missing code in the following code fragment. This fragment is intended to initialize an instance variable. public class Motor { int motorSpeed; public Motor(int speed) { motorSpeed = speed; } public Motor() { _________; } } Which of the following lines of code will allow the second constructor to call the first constructor? a) this.motorspeed(0); b) this(0); c) this(speed); d) You cannot call a constructor from within another constructor.

b

Insert the missing code in the following code fragment. This fragment is intended to initialize an instance variable. public class Vehicle { int numAxles; public Vehicle(int axles) { numAxles = axles; } public Vehicle() { _________; } } Which of the following lines of code will allow the second constructor to call the first constructor? a) this. numAxles(0); b) this(0); c) this(axles); d) this(numAxles

b

Which of the following declares a sideLength instance variable for a Square class that stores an integer value? a) private integer sideLength; b) private int sideLength; c) public integer sideLength; d) public int sideLength;

b

Which of the following statements about classes is correct? a) A class is an object that can be manipulated by a program. b) A class describes a set of objects with the same behavior. c) Class is another name for a method. d) A class can contain only methods.

b

Which of the following statements about constructors is NOT correct? a) A constructor must have the same name as the class name. b) A call to a constructor must always have construction parameters. c) A constructor initializes the instance variables of an object. d) A class can have more than one constructor

b

Which statement about instance variables is correct? a) Instance variables must be declared within a method. b) Instance variables must be declared inside the class, but outside any method. c) Instance variables may be declared inside the class, or inside a method. d) Instance variables must be declared outside the class

b

Which statement illustrates the invocation of a static method? a) mySavings.deposit(100); b) double s = Math.sqrt(100); c) deposit(100).mySavings; d) double s = 100.sqrt();

b

You have created a Rocket class which has a constructor with no parameters. Which of the following statements will construct an object of this class? a) Rocket myRocket; b) Rocket myRocket = new Rocket(); c) myRocket.new(Rocket); d) Rocket.new(myRocket);

b

50) A constructor is invoked when ___ to create an object. a) the class keyword is used b) the class is defined as public c) the new keyword is used d) the class is defined as private

c

78) Insert the missing code in the following code fragment. This fragment is intended to implement a method to get the value stored in an instance variable. public class Vehicle { private String model; private double rpm; . . . _______ { return model; } } a) public void setModel(String modelName) b) public void getModel() c) public String getModel() d) public String setModel(String modelName)

c

Consider the following class: public class Auto { private String make; private String model; private String year; public Auto(String aMake, String aModel, String aYear) { make = aMake; model = aModel; year = aYear; } public String getInfo() { return year + " " + make + " " + model; } } Which of the following code snippets will correctly create an object of this class and display its information? a) myAuto = new Auto(); System.out.println(myAuto.getInfo()); b) Auto myAuto = new Auto(); System.out.println(myAuto.getInfo()); c) Auto myAuto = new Auto("Ford", "Focus", "2011"); System.out.println(myAuto.getInfo()); d) Auto myAuto = new Auto("2011", "Ford", "Focus"); System.out.println(myAuto.getInfo());

c

Consider the following code snippet: public class Employee { private String empID; private boolean hourly; public Employee(String employeeID, boolean isHourly) { . . . } } Which of the following statements can be used to create an object of type Employee? a) Employee anAuto = new Employee(); b) Employee anAuto = new Employee(10548, true); c) Employee anAuto = new Employee("10548", true); d) Employee anAuto = new Employee(10548, "true");

c

Consider the following code snippet: public class Vehicle { private String type; public String Vehicle(String type) { . . . } } What is wrong with this code? a) The class instance variable type must be initialized when it is declared. b) The constructor must not have any arguments. c) The constructor must not have a return type declared. d) The constructor's return type must be void

c

Consider the following code snippet: public class Vessel { private String type; public String Vessel(String type) { . . . } } What is wrong with this code? a) The class instance variable type must be initialized when it is declared. b) The constructor must not have any arguments. c) The constructor must not have a return type declared. d) The constructor's return type must be void

c

Consider the following code snippet: public static class Triangle { public static double getTriangleArea(double heightLen, double baseLen) { . . . } } You are writing a program that needs to use this method. Which of the following statements correctly calls this method? a) Triangle myTriangle = new Triangle(); double area = myTriangle.getTriangleArea(4.0,7.0); b) double area = new Triangle().getTriangleArea(4.0,7.0); c) double area = Triangle.getTriangleArea(4.0, 7.0); d) This method cannot be used outside of the Triangle class.

c

Given the following class definition, which of the following are considered part of the class's public interface? public class CashRegister { public static final double DIME_VALUE = 0.1; private static int objectCounter; public void updateDimes(int dimes) {. . .} private boolean updateCounter(int counter) {. . .} } a) objectCounter and updateCounter b) DIME_VALUE and objectCounter c) DIME_VALUE and updateDimes d) updateDimes and updateCounter

c

Given the following class definition, which of the following are considered part of the class's public interface? public class Motorcycle { public static final int WHEEL_COUNT = 2; private int rpmRating; public void updatePrice(double increase) {...} private String designCode() {...} } a) rpmRating and designCode b) WHEEL_COUNT and designCode c) WHEEL_COUNT and updatePrice d) updatePrice and designCode

c

Given the following class: public class Coin { private String coinName; private double coinValue; . . . } Consider the following code snippet that utilizes the Coin class: Coin coin1 = new Coin("dime", 0.10); Coin coin2 = coin1; coin2.setValue(0.15); Which of the following statements is correct? a) coin1 has a value of 0.10 and coin2 has a value of 0.15. b) coin1 and coin2 both have the value of 0.10. c) coin1 and coin2 both have the value of 0.15. d) coin2 does not have any data in the coinName variable

c

Insert the missing code in the following code fragment. This fragment is intended to implement a method to get the value stored in an instance variable. public class Employee { private String empID; private boolean hourly; . . . _______ { return hourly; } } a) public void setHourly(String isHourly) b) public void getHourly() c) public boolean getHourly() d) public boolean setHourly(boolean isHourly

c

Insert the missing code in the following code fragment. This fragment is intended to initialize an instance variable. public class Employee { private String empName; . . . public Employee(String empName) { ________ } } a) Employee.empName = empName; b) empName = this.empName; c) this.empName = empName; d) The constructor parameter variable cannot have the same name as an instance variable.

c

Insert the missing code in the following code fragment. This fragment is intended to initialize an instance variable. public class Motor { private int motorSpeed; . . . public Motor(int motorSpeed) { ________ } } a) Motor.motorSpeed = motorSpeed; b) motorSpeed = this.motorSpeed; c) this.motorSpeed = motorSpeed; d) The constructor parameter variable cannot have the same name as the instance variable.

c

Which of the following statements about a class is correct? a) A class should not have private instance variables. b) Private instance variables are the interface to the class. c) Private instance variables hide the implementation of a class from the class user. d) Private instance variables should rarely be used in classes.

c

Which of the following statements about class properties is correct? a) A setter method is used to retrieve the value of a class property. b) A getter method is used to assign the value of a class property. c) A setter method is used to assign the value of a class property. d) You cannot assign values to class properties

c

Which of the following statements about encapsulation is correct? a) Encapsulation enables changes to the public interface without affecting users of the class. b) Encapsulation prohibits changes to the implementation details to ensure that users of the class will not be affected. c) Encapsulation enables changes to the implementation details without affecting users of the class. d) Encapsulation provides an easier means of transporting class information

c

Which of the following statements about testing a class is correct? a) A unit test verifies that only one method within a class works correctly. b) A unit test verifies that a class works correctly when it is in a complete program. c) A unit test verifies that a class works correctly in isolation, outside a complete program. d) A unit test does not need to know what results are expected

c

Which of the following is a mutator method of the CashRegister class used in the textbook?

clear

Consider the following class: public class Auto { private String make; private String model; private String year; public Auto(String aMake, String aModel, String aYear) { make = aMake; model = aModel; year = aYear; } public String calcMileage(double milesDriven, double gasUsed) { double milage = milesDriven/gasUsed; return mileage.toString(); } } Which of the following code snippets will correctly create an object of type Auto and display its mileage? a) myAuto = new Auto(); System.out.println(myAuto.calcMileage(246.0, 15.8)); b) Auto myAuto = new Auto(); System.out.println(myAuto.calcMileage(246.0, 15.8)); c) Auto myAuto = new Auto("2011", "Ford", "Focus"); System.out.println(myAuto.calcMileage(246.0, 15.8)); d) Auto myAuto = new Auto("Ford", "Focus", "2011"); System.out.println(myAuto.calcMileage(246.0, 15.8));

d

Consider the following code snippet: Coin coin1 = new Coin("dime", 0.10); Coin coin2 = coin1; Which of the following statements is NOT correct? a) coin1 and coin2 are object references. b) coin1 and coin2 refer to the same object. c) coin1 and coin2 contain the same memory location. d) coin1 and coin2 each have their own set of instance variables.

d

Consider the following code snippet: Coin coin1 = new Coin("dime", 0.10); Coin coin2 = new Coin("dime", 0.10); Which of the following statements is correct? a) coin1 and coin2 contain references to the same object. b) coin1 and coin2 refer to the same object. c) coin1 and coin2 contain the same memory location. d) coin1 and coin2 each have their own set of instance variables.

d

Consider the following code snippet: public class Coin { private String coinName; private int coinValue; public Coin() { } . . . } Which statement reflects the action performed when the constructor to Coin is called? a) The variable coinName will be initialized to "" and the variable coinValue will be initialized to 0. b) The variable coinName will be initialized to "null" and the variable coinValue will be initialized to 0. c) The variable coinName will not be initialized but the variable coinValue will be initialized to 0. d) The variable coinName will be initialized to null and the variable coinValue will be initialized to 0.

d

Consider the following code snippet: public class Employee { private String empID; private boolean hourly; public Employee() { } . . . } Which statement reflects the action performed when the constructor to Employee is called? a) The variable empID will be initialized to "" and the variable hourly will be initialized to false. b) The variable empID will be initialized to "null" and the variable hourly will be initialized to true. c) The variable empID will not be initialized but the variable hourly will be initialized to false. d) The variable empID will be initialized to null and the variable hourly will be initialized to false.

d

Consider the following code snippet: public class Vehicle { private String type; private int numAxles; public Vehicle() { } . . . } Which statement reflects the action performed when the constructor to Vehicle is called? a) The variable type will be initialized to "" and the variable numAxles will be initialized to 0. b) The variable type will be initialized to "null" and the variable numAxles will be initialized to 0. c) The variable type will not be initialized but the variable numAxles will be initialized to 0. d) The variable type will be initialized to null and the variable numAxles will be initialized to 0.

d

Consider the following code snippet: public class Vehicle { private String type; private int numAxles; public Vehicle(String vehicleType, int VehicleAxles) { . . . } } Which of the following statements can be used to create an object of type Vehicle? a) Vehicle anAuto = new Vehicle(); b) Vehicle anAuto = new Vehicle(2, "SUV"); c) Vehicle anAuto = new Vehicle("SUV", "2"); d) Vehicle anAuto = new Vehicle("SUV", 2);

d

Consider the following code snippet: public class Vehicle { private String type; private int numAxles; public Vehicle(String vehicleType, int VehicleAxles) { . . . } public Vehicle(String vehicleType) { . . . } } What is wrong with this code? a) There must be a default constructor with no arguments. b) A class cannot have more than one constructor. c) If a class has more than one constructor, each one should have a unique name. d) There is nothing wrong with this code.

d

Consider the following code snippet: public class Vehicle { private String type; private int numAxles; public void Vehicle(String vehicleType, int VehicleAxles) { . . . } } What is wrong with this code? a) There must be a default constructor with no arguments. b) The class instance variables must be initialized in the declaration statements. c) The constructor declaration must have a return type of String. d) The constructor declaration must not have any return type

d

Insert the missing code in the following code fragment. This fragment is intended to implement a method to set the value stored in an instance variable. public class Employee { private String empID; private boolean hourly; . . . _______ { hourly = isHourly; } } a) public void setHourly(String isHourly) b) public void getHourly() c) public boolean getHourly() d) public boolean setHourly(boolean isHourly)

d

Which of the following lists the correct order of items in an instance method declaration? a) the return type, the name of the method, and a list of the parameters (if any) b) modifiers, the type of the instance variable, and the name of the instance variable c) the type of the instance variable, modifiers, and a list of the parameters (if any) d) modifiers, a return type, a method name, and a list of the parameters (if any)

d

Which of the following statements about classes is correct? a) All instance variables and most instance methods should be declared as public. b) All instance variables and most instance methods should be declared as private. c) All instance variables should be declared as public and most instance methods should be declared as private. d) All instance variables should be declared as private and most instance methods should be declared as public

d

Which of the following statements about constructors is correct? a) A class can have only one constructor. b) A constructor should always return a value. c) A class must have at least one constructor supplied by the programmer. d) A constructor must have the same name as the class.

d

Which of the following statements about encapsulation is correct? a) To use encapsulation, you must provide a set of private methods in the class. b) To use encapsulation, the class must contain only public methods in the class. c) To use encapsulation, the implementation details must be public. d) To use encapsulation, you must provide a set of public methods in the class and hide the implementation details

d

Which of the following statements about instance methods is correct? a) An instance method should always be declared as public. b) An instance method should always be declared as private. c) An instance method should be declared as public only if it is a helper method. d) An instance method should be declared as private only if it is a helper method.

d

Which of the following statements using data values in a class is NOT correct? a) You can use an instance variable's data value in an instance method. b) You can use the argument of an instance method in that method. c) You can use a global constant's value in an instance method. d) You can use the argument of any instance method in any other method.

d

The process of hiding object data and providing methods for data access is called ____.

encapsulation

Input to a method enclosed in parentheses after the method name is known as ____.

explicit parameters

Which of the following is an accessor method of the CashRegister class used in the textbook?

getTotal

The object on which a method is invoked is called the ____.

implicit parameter

The this reference refers to ____.

implicit parameter

When an object is created from a class, the object is called a/an ____ of the class.

instance

Data required for an object's use are stored in ____.

instance variable

Each object of a class has a separate copy of each ___.

instance variable

The public constructors and methods of a class form the public _____ of the class.

interface

The utility that formats program comments into a set of documents that you can view in a Web browser is called ____.

javadoc

A method in a class that modifies information about an object is called a/an ____ method.

mutator

Which type of method modifies the object on which it is invoked?

mutator method

The ____ operator is used to construct an object from a class.

new

You should declare all instance variables as ___.

private

You are creating a class named Employee. Which statement correctly declares a constructor for this class?

public Employee ( )

You are creating a class named Vessel. Which statement correctly declares a constructor for this class?

public Vessel ()

What type of method does NOT operate on an object?

static

Which of the following statements about objects is correct?

Every object has its own set of data and a set of methods to manipulate the data. c

Complete the following code snippet to create a constructor that will initialize the class instance variables shown using data provided by the program which is creating an object from this class. public class Employee { private String empID; private boolean hourly; _______________________ { . . . } } Which of the following statements can be used to create an object of type Employee? a) public Employee(String employeeID, boolean isHourly) b) public Employee(employeeID, isHourly) c) public Employee(empID, Hourly) d) public Employee()

a

Consider the following code snippet: public class Coin { private String coinName; public String getCoinValue() { . . . } } Which of the following statements is correct? a) The getCoinValue method can be accessed by any user of a Coin object. b) The getCoinValue method can be accessed only by methods of the Coin class. c) The getCoinValue method can be accessed only by methods of another class. d) The getCoinValue method cannot be accessed at all.

a

Consider the following code snippet: public class Employee { private String empName; public String getEmpName() { . . . } } Which of the following statements is correct? a) The getEmpName method can be accessed by any user of an Employee object. b) The getEmpName method can be accessed only by methods of the Employee class. c) The getEmpName method can be accessed only by methods of another class. d) The getEmpName method cannot be accessed at all.

a

Consider the following code snippet: public class Vehicle { . . . public void setVehicleAttributes(String attributes) {. . . } public String getVehicleAtrributes() {. . . } public String getModelName() {. . . } } Assuming that the names of the methods reflect their action, which of the following statements about these instance methods is NOT correct? a) setVehicleAttributes is an accessor method. b) setVehicleAttributes is a mutator method. c) getVehicleAttributes is an accessor method. d) getModelName is an accessor method.

a

Consider the following code snippet: public class Vehicle { private String model; private double rpm; . . . } Which of the following methods would correctly remove the values of the class instance variables? a) public void reset() { model = null; rpm = 0; } b) public void reset() { model.clear(); rpm = 0; } c) public void reset(String aModel, double theRpm) { model = aModel; rpm = theRpm; } d) public void reset("",0) { }

a

Given the following class definition, which of the following are NOT considered part of the class's public interface? public class CashRegister { public static final double DIME_VALUE = 0.1; private static int objectCounter; public void updateDimes(int dimes) {...} private boolean updateCounter(int counter) {...} } a) objectCounter and updateCounter b) DIME_VALUE and objectCounter c) DIME_VALUE and updateDimes d) updateDimes and updateCounter

a

Given the following class definition, which of the following are NOT considered part of the class's public interface? public class Motorcycle { public static final int WHEEL_COUNT = 2; private int rpmRating; public void updatePrice(double increase) {...} private String designCode() {...} } a) rpmRating and designCode b) WHEEL_COUNT and designCode c) WHEEL_COUNT and updatePrice d) updatePrice and designCode

a

Insert the missing code in the following code fragment. This fragment is intended to implement a method to assign a value to an instance variable. public class Vehicle { private String model; private double rpm; . . . _______ { model = modelName; } } a) public void setModel(String modelName) b) public void getModel() c) public String getModel() d) public String setModel(String modelName

a

Insert the missing code in the following code fragment. This fragment is intended to implement a method to increase the speed of the motor by one step if possible. public class Motor { public static final STOPPED = 0; public static final SLOW = 1; public static final MEDIUM = 2; public static final FAST = 3; private int motorSpeed; . . . public void increaseMotorSpeed() { if(motorSpeed < FAST) { ________ } } } a) motorSpeed ++; b) motorSpeed = SLOW; c) motorSpeed = MEDIUM; d) motorSpeed = FAST;

a

Which of the following is NOT part of the declaration of an instance variable? a) the return type b) a modifier specifying the level of access c) the data type d) the name

a


Set pelajaran terkait

Physics exam 1 CH 1-4 study guide

View Set

Chapter 32 - Fetal Environment and Maternal Complications

View Set