IT 206 lab exam 2023
Consider the following code, part of an implemenation class.
Course myCourse = new Course("IT 206", 90);
myCourse = new
... [Show More] Course("IT 206", 120);
Which of the following is true after attempting to execute this code? - ANSWER-myCourse would reference the second Course object with enrollment of 120 and make the first Course object available for garbage collection
Consider the following code, part of a data definition class.
public class Student {
private String name;
private double gpa;
public void Student(String name, double gpa) {
// Code within constructor
}
} - ANSWER-none of the other answers are correct
Assume you have created a data definition class to represent a Rocket, but have not provided any constructors within the data defnition class. Which of the following statements will construct an object of this class? - ANSWER-Rocket myRocket = new Rocket();
Constructors are invoked when which of the following occurs while creating an object? - ANSWER-the new keyword is used
Consider the following data definition class meant to represent a Car.
public class Car {
private int maxSpeed;
public Car(int maxSpeed) {
// Missing Code Here
}
} - ANSWER-this.maxSpeed = maxSpeed;
Consider the following data definition class to represent one room of a house.
public class Room {
public double length;
public double width;
public String roomName;
public double getLength() { return this.length; }
public double getWidth() { return this.width; }
public String getRoomName() { return this.roomName; }
} - ANSWER-this class violates the concept of information hiding
Assume you have an instance variable within a data definition class that you wish to make available for an implementation class to read its value. What should you create? - ANSWER-an accessor method
Assume you want to solve a problem by creating a blueprint or prototype that defines all attributes and behaviors common to all instances of the blueprint. What should you create? - ANSWER-a class
In order to use encapsulation, which of the following statements is correct? - ANSWER-you must provide a set of public methods in a data definition class and hide the implementation details
Which of the following statements about classes is correct? - ANSWER-None of the other answers are correct
Consider the following data definition class to represent one cash register. [Show Less]