Exam 8: Objects and Classes

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Consider the following code snippet: Public class Employee { Private String empName; ) . . } Which of the following statements is correct?

(Multiple Choice)
4.9/5
(39)

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?

(Multiple Choice)
4.9/5
(33)

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?

(Multiple Choice)
4.9/5
(33)

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?

(Multiple Choice)
4.8/5
(32)

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?

(Multiple Choice)
4.8/5
(33)

Consider the following code snippet: Public class Coin { Private String coinName; ) . . } Which of the following statements is correct?

(Multiple Choice)
4.9/5
(41)

What type of method does NOT operate on an object?

(Multiple Choice)
4.8/5
(30)

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

(Multiple Choice)
4.9/5
(40)

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?

(Multiple Choice)
4.7/5
(45)

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?

(Multiple Choice)
4.8/5
(37)

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?

(Multiple Choice)
4.9/5
(38)

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?

(Multiple Choice)
4.8/5
(34)

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?

(Multiple Choice)
4.9/5
(39)

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?

(Multiple Choice)
4.8/5
(41)

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?

(Multiple Choice)
4.8/5
(46)

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) { ________ } } }

(Multiple Choice)
4.8/5
(37)

Which of the following statements about objects is correct?

(Multiple Choice)
4.9/5
(40)

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

(Multiple Choice)
4.9/5
(35)

Consider the following code snippet: Public class Coin { Private String coinName; Public String getCoinValue() { ) . . } } Which of the following statements is correct?

(Multiple Choice)
4.9/5
(37)

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() { ________ } }

(Multiple Choice)
4.7/5
(34)
Showing 41 - 60 of 101
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)