2023 objects __________.
a. do not encapsulate
b. data persist forever after being instantiated
c. contain only accessor methods
d. have state and behavior
23. Given the following code fragment. (presume there is a Hat class with a constructor that requires the hat type | Assignment Collections
Computer Science 2023 A+ Answers
2023 objects __________.
a. do not encapsulate
b. data persist forever after being instantiated
c. contain only accessor methods
d. have state and behavior
23. Given the following code fragment. (presume there is a Hat class with a constructor that requires the hat type | Assignment Collections
2. Which is the correct syntax for a mutator method?
a. public int getWeight() { return this.weight; }
b. public boolean isDeclawed() { return this.declawed; }
c. public void getWeight() { return this.weight; }
d. public void setWeight(double weight) { this.weight = weight; }
3. Which statement shows the correct way to declare and initialize a named constant that represents absolute zero?
a. final int absoluteZero = -273.15;
b. final double absoluteZero = -273.15;
c. final int ABSOLUTE_ZERO = -273.15;
d. final double ABSOLUTE_ZERO = -273.15;
4. In the following class: public class Height { private double height; private String unitsOfMeasurement; //************************ public Height()
{ this.unitsOfMeasurement = “in”; }
public void setHeight(double height)
{ this.height = height; this.unitsOfMeasurement = “cm”; }
public void setHeight(double height, String unitsOfMeasurement) { this.height = height; this.unitsOfMeasurement = unitsOfMeasurement; }
public void print() { System.out.println(this.height + ” ” + this.unitsOfMeasurement); } } // end class Height
Which method is the constructor?
The print method
The Height method
The setHeight method
This class does not implement a constructor.
5. Java primitive types include _________.
integer, double, string, boolean, long and float
integer, double, float, array, boolean and long
long, integer, string, array, float, double and character
long, double, character, float, integer and boolean
6. What is the name for the circled items in the following statement?
What is the name for the circled items in the following statement?
modulus specifier
format specifier
flags specifier
precision specifier
7. Which Java operator is used for concatenation?
&&
+
.
||
8. Given the following code fragment (presume there is a class called Car implemented):
Car mazdaCar = new Car();
mazdaCar.setYear(2008);
mazdaCar.setColor(black);
subaruCar = mazdaCar;
subaruCar.setYear(2011);
mazdaCar.printYear();
What will display on the screen for mazdaCars year when mazdaCar executes printYear()?
a. 2008
b. 2010
c. 2011
d. Black
9. Given the following method from a class: public double calculateArea(double length, double width) { double area; area = length * width; return area; }
What is the scope of the variables length and width?
a. Global to the class.
b. Local to the method.
c. Global to all objects created from the class.
d. None of the above.
10. In the following code fragment:
5 Person person1 = new Person();
6 Person person2 = new Person();
7 8 person1.setName(“Bugs Bunny”);
9 person2.setName(“Daffy Duck”);
10 System.out.println(person1.getName() + “, ” + person2.getName()); 11 12 person1.swapPerson(person2); 13 System.out.println(person1.getName() + “, ” + person2.getName());
What is being passed to the swapPerson method in line 12:
a. an object
b. an object reference
c. a class
d. a class reference
11. In the following Java code fragment:
int postion1 = 15;
int postion2 = 18;
int distanceApart = Math.abs(position1 – position2);
What type of method is the Math.abs() method?
a. Instance method
b. Class method
c. Final method
d. Inherited method
12. When a public method needs to access both class members (variables and methods) and instance members (variables and methods), the method must be a / an _________ method.
a. instance
b. helper
c. class
d. None of the above.
13. In the following class:
public class Height { private double height; private String unitsOfMeasurement;
public Height() { this.unitsOfMeasurement = “in”; }
public void setHeight(double height) { this.height = height; this.unitsOfMeasurement = “cm”; }
public void setHeight(double height, String unitsOfMeasurement) { this.height = height; this.unitsOfMeasurement = unitsOfMeasurement; }
public void print() { System.out.println(this.height + ” ” + this.unitsOfMeasurement); } } // end class Height Which method is overloaded?
a. The print method
b. The Height method
c. The setHeight method
c. None of the methods are overloaded.
14. What must a method return if the method implements method call chaining?
The calling object
A class variable
The class
Null
15.
Which code segment is representative of a properly formatted nested loop?
a. while(i<5) { }
b. while(j<3) { } do { while(j<3) { } }
c. while(i<5); do { while(j<3) { } }
d. while(i<5) while(i<5) { while(j<3) { }do; }
no answer matches
16. What is the fundamental difference between a do loop and a while loop?
a. Code inside a do loop will never be executed.
b. Code inside a while loop is guaranteed to execute at least once.
c. Code inside a do loop is guaranteed to execute at least once.
d. Do loops and while loops are the same.
17. What is the meaning of the java statement: import java.util.Scanner;?
a. It tells the java compiler to include the Scanner class from the utility package.
b. It tells the java compiler to exclude only the Scanner class from the compile process.
c. It signals the java compiler to scan the source code for errors.
d. None of the above.
18. Given the following code fragment: double interestRate = 0.05; double balance = 100.5; int interestInDollars = (int)(interestRate * balance); System.out.println(interestInDollars);
What value will display on the screen?
a. 5
b. 5.025
c. 5.03
d. 0
19. What is the significance of using the access modifier private with instance variables?
a. It makes instance variables easier to access from outside the object.
b. Using private provides data encapsulation.
c. It makes the variables inaccessible from within the object.
d. The private access modifier should never be used.
20. Given the following code fragment: System.out.println(“”Four score and seven years ago””””);
What will display on the screen?
a. Four score and seven years ago
b. Four score and seven years ago
c. Four score and seven years ago
d. “”””Four score and seven years ago””””
It will display:
“”Four score and seven years ago””
Match your answer accordingly
21. Given the following
We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.
Place Order Now
a. do not encapsulate
b. data persist forever after being instantiated
c. contain only accessor methods
d. have state and behavior
23. Given the following code fragment. (presume there is a Hat class with a constructor that requires the hat type | Assignment Collections