Exam 8: Objects and Classes
Exam 1: Introduction96 Questions
Exam 2: Fundamental Data Types103 Questions
Exam 3: Decisionseasy99 Questions
Exam 4: Loops100 Questions
Exam 5: Methods94 Questions
Exam 6: Arrays and Arraylists100 Questions
Exam 7: Inputoutput and Exception Handling100 Questions
Exam 8: Objects and Classes101 Questions
Exam 9: Inheritance and Interfaces99 Questions
Exam 10: Graphical User Interfaces54 Questions
Exam 11: Advanced User Interfaces91 Questions
Exam 12: Object-Oriented Design100 Questions
Exam 13: Recursion100 Questions
Exam 14: Sorting and Searching99 Questions
Exam 15: The Java Collections Framework100 Questions
Exam 16: Basic Data Structures94 Questions
Exam 17: Tree Structures100 Questions
Exam 18: Generic Classes78 Questions
Exam 19: Streams and Binary Inputoutput82 Questions
Exam 20: Multithreading82 Questions
Exam 21: Internet Networking74 Questions
Exam 22: Relational Databases75 Questions
Exam 23: XML74 Questions
Exam 24: Web Applications74 Questions
Select questions type
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?
(Multiple Choice)
4.7/5
(40)
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)
{
________
}
}
(Multiple Choice)
5.0/5
(36)
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?
(Multiple Choice)
4.8/5
(40)
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?
(Multiple Choice)
4.7/5
(44)
Which choice indicates that a string variable refers to no string?
(Multiple Choice)
4.9/5
(40)
Which statement calls a constructor with no construction parameters?
(Multiple Choice)
4.9/5
(39)
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?
(Multiple Choice)
4.8/5
(31)
Which of the following statements about class properties is correct?
(Multiple Choice)
4.8/5
(39)
If you do not provide a constructor in a class, which of the following is correct?
(Multiple Choice)
4.9/5
(31)
Which of the following statements about constructors is NOT correct?
(Multiple Choice)
4.9/5
(30)
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?
(Multiple Choice)
4.7/5
(34)
A method in a class that returns information about an object but does not change the object is called a/an ____ method.
(Multiple Choice)
4.8/5
(36)
Which of the following statements is true regarding classes?
(Multiple Choice)
4.9/5
(33)
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?
(Multiple Choice)
4.9/5
(35)
Consider the following code snippet:
Public class Vehicle
{
Private String type;
Public String Vehicle(String type)
{
) . .
}
}
What is wrong with this code?
(Multiple Choice)
4.9/5
(38)
Which of the following statements about classes is correct?
(Multiple Choice)
4.8/5
(49)
When an object is created from a class, the object is called a/an ____ of the class.
(Multiple Choice)
4.8/5
(31)
You have created a Fruit class and a ShoppingCart class. Which of the following methods will correctly add a Fruit object to an array list named fruits in the ShoppingCart class?
(Multiple Choice)
4.8/5
(30)
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?
(Multiple Choice)
4.9/5
(44)
Showing 21 - 40 of 101
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)