quiz 4
.docx
keyboard_arrow_up
School
Clayton State University *
*We aren’t endorsed by this school
Course
1000
Subject
Computer Science
Date
Feb 20, 2024
Type
docx
Pages
9
Uploaded by CaptainKomodoDragon3151
The key word
this
is the name of a reference variable that an object can use to refer to itself.
Question options:
True
False
on An instance of a class does not have to exist in order for values to be stored in a class's static fields.
Question options:
True
False
on A class's static methods do not operate on the fields that belong to any instance of the class.
Question options:
True
False
on If you write a
toString
method for a class, Java will automatically call the method any time you concatenate an object of the class with a string.
Question options:
True
False
on When an object is passed as an argument, it is actually a reference to the object that is passed.
Question options:
True
False
on Both instance fields and instance methods are associated with a specific instance of a class, and they cannot be used until an instance of the class is created.
Question options:
True
False
on A single copy of a class's static field is shared by all instances of the class.
Question options:
True
False
on When an object reference is passed to a method, the method may change the values in the object.
Question options:
True
False
on If you write a
toString
method to display the contents of an object,
object1
, for a class,
Class1
, then the following two statements are equivalent:
System.out.println(object1);
System.out.println(object1.toString());
Question options:
True
False
on The only limitation that static methods have is ________.
Question options:
A)
they must be declared outside of the class
B)
they cannot refer to nonstatic members of the class
C)
they can only be called from static members of the class
D)
they can refer only to nonstatic members of the class
on Static methods can only operate on ________ fields.
Question options:
A)
instance
B)
local
C)
global
D)
static
on When you make a copy of the aggregate object and of the objects that it references, ________.
Question options:
A)
a compiler error will occur
B)
you are performing a nested copy
C)
you are performing a shallow copy
D)
you are performing a deep copy
on A deep copy of an object ________.
Question options:
A)
is an operation that copies an aggregate object and all the objects that it references
B)
is always a private method
C)
is a bogus term and means nothing
D)
is an assignment of that object to another object
on The JVM periodically performs the ________ process to remove unreferenced objects from memory.
Question options:
A)
memory sweeping
B)
memory shuffling
C)
system restore
D)
garbage collection
on When the
this
variable is used to call a constructor ________.
Question options:
A)
it must be the first statement in the constructor making the call
B)
it can be anywhere in the constructor making the call
C)
it must be the last statement in the constructor making the call
D)
None of these. You cannot use the
this
variable in a constructor call.
on When a reference variable is passed as an argument to a method ________.
Question options:
A)
the method becomes a static method
B)
the method has access to the object that the variable references
C)
a copy of the variable's value is passed into the method's parameter
D)
the program terminates
on When a method's return type is a class, what is actually returned to the calling program?
Question options:
A)
an object of that class
B)
a reference to an object of that class
C)
the values in the object that the method accessed
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
java
Assignment Description:
Write a class named Car that has the following fields:
The yearModel field is an int that holds the car’s year model.
The make field references a String object that holds the make of the car.
The speed field is an int that holds the car’s current speed.
In addition, the class should have the following constructor and other methods.
The constructor should accept the car’s year and make as arguments. These values should be assigned to the object’s yearModel and make fields. The constructor should also assign 0 to the speed field.
Constructor: The constructor should accept no arguments.
Constructor: The constructor should accept the car’s year as argument.Assign the value to the object’s yearModel. No need to assign anything to the make and assign 0 to speed.
Appropriate mutator methods should set the values in an object’s yearModel, make, and speed fields.
Appropriate accessor methods should get the values stored in an object’s yearModel, make, and…
arrow_forward
Focus on classes, objects, methods and good programming style
Your task is to create a BankAccount class.
Class name
BankAccount
Attributes
_balance
float
_pin
integer
Methods
init ()
get_pin()
check pin ()
deposit ()
withdraw ()
get_balance ()
The bank account will be protected by a 4-digit pin number (i.e. between 1000 and 9999). The
pin should be generated randomly when the account object is created. The initial balance should
be 0.
get_pin () should return the pin.
check_pin (pin) should check the argument against the saved pin and return True if it
matches, False if it does not.
deposit (amount) should receive the amount as the argument, add the amount to the account
and return the new balance.
withraw (amount) should check if the amount can be withdrawn (not more than is in
the account), If so, remove the argument amount from the account and return the new balance if
the transaction was successful. Return False if it was not.
get_balance () should return the current balance.…
arrow_forward
True or FalseIt is a common practice to make all a class’s fields private and to provide access to those fields through methods.
arrow_forward
True or False Class fields are almost always declared public in order to make their values easily accessible to code outside of the class.
arrow_forward
T/F: Instance variables are shared by all the instances of the class.
T/F: The scope of instance and static variables is the entire class. They can be declared anywhere inside a class.
T/F: To declare static variables, constants, and methods, use the static modifier.
arrow_forward
A
is a method that is automatically called when an object is instantiated.
arrow_forward
In a Java class, the method that creates an object by using the new operator is called the ___.
mutator
accessor
toString
constructor
arrow_forward
Activity 1 - C++ Language
Write a C++ class with the following properties and methods
Create a class named BANK ACCOUNT
with public properties ACCOUNT NUMBER and BALANCE;
- Create a method DEPOSIT that accepts an argument AMOUNT
Which stores/add the given AMOUNT in the BALANCE property.
- Create a method WITHDRAW that accepts an argument AMOUNT
Check the AMOUNT value if less than or equal to the object's BALANCE.
Deduct AMOUNT from the current BALANCE if true and return true;
Return false if the condition wasn't met.
Create a method DISPLAY to show the ACCOUNT NUMBER and current BALANCE of the object
arrow_forward
The reference this can be used to refer to an object or to invoke another
constructor of the same class.
True
False
arrow_forward
INVENTORY CLASS
You need to create an Inventory class containing the private data fields, as well as the
methods for the Inventory class (object).
Be sure your Inventory class defines the private data fields, at least one constructor,
accessor and mutator methods, method overloading (to handle the data coming into the
Inventory class as either a String and/or int/float), as well as all of the methods (methods
to calculate) to manipulate the Inventory class (object).
The data fields in the Inventory class include the inventory product number (int),
inventory product description (String), inventory product price (float), inventory quantity
on hand (int), inventory quantity on order (int), and inventory quantity sold (int).
The Inventory class (java file) should also contain all of the static data fields, as well as
static methods to handle the logic in counting all of the objects processed (counter), as
well as totals (accumulators) for the total product inventory and the total product…
arrow_forward
True or FalseIn structs, all fields and methods are public i.e. all the data can be accessed and changed and all the methods can be called by those who use it.
arrow_forward
In Java
Know the correct syntax to write a Student class: fields name and grade ; constructors; display method: include default and overloaded constructor
arrow_forward
Focus on classes, objects, methods and good programming style
Your task is to create a BankAccount class(See the pic attached)
The bank account will be protected by a 4-digit pin number (i.e. between 1000 and 9999). The pin should be generated randomly when the account object is created. The initial balance should be 0.
get_pin()should return the pin.
check_pin(pin) should check the argument against the saved pin and return True if it matches, False if it does not.
deposit(amount) should receive the amount as the argument, add the amount to the account and return the new balance.
withraw(amount) should check if the amount can be withdrawn (not more than is in the account), If so, remove the argument amount from the account and return the new balance if the transaction was successful. Return False if it was not.
get_balance() should return the current balance.
Finally, write a main() to demo your bank account class. Present a menu offering a few actions and perform the action the user…
arrow_forward
True or False The get accessor can be thought of as a method that returns the class property’s value.
arrow_forward
JAVA
arrow_forward
in C# i need to
Create a BankAccount class with the following properties:
Account Number (string)
Account Holder Name (string)
Balance (double)
Account Type (enum: Savings, Current)
Create the following methods in the BankAccount class:
Deposit(double amount): Method to deposit money into the account
Withdraw(double amount): Method to withdraw money from the account
CheckBalance(): Method to check the current balance of the account
Create a Bank class with the following properties:
List of bank accounts (List<BankAccount>)
Create the following methods in the Bank class:
AddAccount(BankAccount account): Method to add a new bank account to the list of accounts
RemoveAccount(string accountNumber): Method to remove an existing bank account from the list of accounts
SearchAccount(string accountNumber): Method to search for an existing bank account and return the account details
Create a Program class with the Main method, and implement the following functionality:…
arrow_forward
Please help with the following: C# .NET
change the main class so that the user is the one that as to put the name Write a driver class (app) that prompts for the person’s data input, instantiates an object of class HeartRates and displays the patient’s information from that object by calling the DisplayPatientRecord, method.
MAIN CLASS----------------------
static void Main(string[] args) { // instance of patient record with each of the 4 parameters taking in a value HeartRates heartRate = new HeartRates("James", "Kill", 1988, 2021); heartRate.DisplayPatientRecord(); // call the method to display The Patient Record }
CLASS HeartRATES-------------------
class HeartRates { //class attributes private private string _First_Name; private string _Last_Name; private int _Birth_Year; private int _Current_Year; // Constructor which receives private parameters to initialize variables public HeartRates(string First_Name, string Last_Name, int Birth_Year, int Current_Year) { _First_Name =…
arrow_forward
A special static method named
is used to provide a starting point for
the execution of a program using the class that declares it. *
arrow_forward
#pyhton programing
topic: Introduction to Method and Designing class
Method overloading & Constructor overloading
------------------
please find the attached image
arrow_forward
Assignment:
1- Create a class called Book with the following attributes:
1. title: The title of the book.
2. author: The author of the book.
3. pages: The number of pages in the book.
Use a constructor (__init___) to initialize these attributes when creating an object
from the class. Add a method inside the class calle description() which returns a
description of the book
Lec 3: Classes and Objects
Object-oriented programming
2- Create a class called Phone with the following attributes:
1. brand: The brand of the phone.
2. price: The price of the phone.
Use a constructor (__init__) to initialize these attributes when creating an object
from the class. Add a method inside the class called show_info(), which prints the
phone's details
arrow_forward
Question -
Create a class named Pizza with the following data fields:
description - of type String
price - of type double
The description stores the type of pizza (such as sausage and onion). Include a constructor that requires arguments for both fields and a method named display to display the data. For example, if the description is 'sausage and onion' and the price is '14.99', the display method should output:
sausage and onion pizza Price: $14.99
Create a subclass named DeliveryPizza that inherits from Pizza but adds the following data fields:
deliveryFee - of type double
address - of type String
The description, price, and delivery address are required as arguments to the constructor. The delivery fee is $3 if the pizza ordered costs more than $15; otherwise it is $5.
Code that is not accepted -
class DeliveryPizza extends Pizza
{
private double deliveryFee;
private String address;
public DeliveryPizza(String desc, double price, double deliveryFee, String address){…
arrow_forward
It is customary that we write this method to return a string representation of objects in a class.
constructor
mutator
toString
accessor
arrow_forward
java
If the first statement of a constructor has the form this(. . .), then the constructor calls another constructor of the same class.
Select one:
True
False
arrow_forward
in c# i need to
Create a BankAccount class with the following properties:
Account Number (string)Account Holder Name (string)Balance (double)Account Type (enum: Savings, Current)Create the following methods in the BankAccount class:
Deposit(double amount): Method to deposit money into the accountWithdraw(double amount): Method to withdraw money from the accountCheckBalance(): Method to check the current balance of the account
I am getting a error in pic
my code is
// Define an enumeration type for bank account typespublic enum AccountType{ Savings, Current}
// Define a class for bank accountspublic class BankAccount{ // Properties for the account number, account holder name, balance and account type public string AccountNumber { get; set; } public string AccountHolderName { get; set; } public double Balance { get; set; } public AccountType AccountType { get; set; }
// Method to deposit money into the account public void Deposit(double amount) {…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Related Questions
- java Assignment Description: Write a class named Car that has the following fields: The yearModel field is an int that holds the car’s year model. The make field references a String object that holds the make of the car. The speed field is an int that holds the car’s current speed. In addition, the class should have the following constructor and other methods. The constructor should accept the car’s year and make as arguments. These values should be assigned to the object’s yearModel and make fields. The constructor should also assign 0 to the speed field. Constructor: The constructor should accept no arguments. Constructor: The constructor should accept the car’s year as argument.Assign the value to the object’s yearModel. No need to assign anything to the make and assign 0 to speed. Appropriate mutator methods should set the values in an object’s yearModel, make, and speed fields. Appropriate accessor methods should get the values stored in an object’s yearModel, make, and…arrow_forwardFocus on classes, objects, methods and good programming style Your task is to create a BankAccount class. Class name BankAccount Attributes _balance float _pin integer Methods init () get_pin() check pin () deposit () withdraw () get_balance () The bank account will be protected by a 4-digit pin number (i.e. between 1000 and 9999). The pin should be generated randomly when the account object is created. The initial balance should be 0. get_pin () should return the pin. check_pin (pin) should check the argument against the saved pin and return True if it matches, False if it does not. deposit (amount) should receive the amount as the argument, add the amount to the account and return the new balance. withraw (amount) should check if the amount can be withdrawn (not more than is in the account), If so, remove the argument amount from the account and return the new balance if the transaction was successful. Return False if it was not. get_balance () should return the current balance.…arrow_forwardTrue or FalseIt is a common practice to make all a class’s fields private and to provide access to those fields through methods.arrow_forward
- True or False Class fields are almost always declared public in order to make their values easily accessible to code outside of the class.arrow_forwardT/F: Instance variables are shared by all the instances of the class. T/F: The scope of instance and static variables is the entire class. They can be declared anywhere inside a class. T/F: To declare static variables, constants, and methods, use the static modifier.arrow_forwardA is a method that is automatically called when an object is instantiated.arrow_forward
- In a Java class, the method that creates an object by using the new operator is called the ___. mutator accessor toString constructorarrow_forwardActivity 1 - C++ Language Write a C++ class with the following properties and methods Create a class named BANK ACCOUNT with public properties ACCOUNT NUMBER and BALANCE; - Create a method DEPOSIT that accepts an argument AMOUNT Which stores/add the given AMOUNT in the BALANCE property. - Create a method WITHDRAW that accepts an argument AMOUNT Check the AMOUNT value if less than or equal to the object's BALANCE. Deduct AMOUNT from the current BALANCE if true and return true; Return false if the condition wasn't met. Create a method DISPLAY to show the ACCOUNT NUMBER and current BALANCE of the objectarrow_forwardThe reference this can be used to refer to an object or to invoke another constructor of the same class. True Falsearrow_forward
- INVENTORY CLASS You need to create an Inventory class containing the private data fields, as well as the methods for the Inventory class (object). Be sure your Inventory class defines the private data fields, at least one constructor, accessor and mutator methods, method overloading (to handle the data coming into the Inventory class as either a String and/or int/float), as well as all of the methods (methods to calculate) to manipulate the Inventory class (object). The data fields in the Inventory class include the inventory product number (int), inventory product description (String), inventory product price (float), inventory quantity on hand (int), inventory quantity on order (int), and inventory quantity sold (int). The Inventory class (java file) should also contain all of the static data fields, as well as static methods to handle the logic in counting all of the objects processed (counter), as well as totals (accumulators) for the total product inventory and the total product…arrow_forwardTrue or FalseIn structs, all fields and methods are public i.e. all the data can be accessed and changed and all the methods can be called by those who use it.arrow_forwardIn Java Know the correct syntax to write a Student class: fields name and grade ; constructors; display method: include default and overloaded constructorarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT