quiz 4

docx

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

Report
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
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
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
D)  nothing - the return type is simply for documentation in this situation on In Java it is possible to write a method that will return ________. Question options: A)  a whole number t B)  a reference to an object C)  a string of characters D)  Any of these on You cannot use the  ==  operator to compare the contents of ________. Question options: A)  objects B)  Boolean values C)  strings D)  integers on An object's ________ is simply the data that is stored in the object's fields at any given moment. Question options: A)  state B)  value C)  assessment
D)  record on A static field is created by placing the key word  static  ________. Question options: A)  after the field name B)  in brackets, before the field's data type C)  after the access specifier and before the field's data type D)  after the access specifier and the field's data type on When a field is declared  static  there will be ________. Question options: A)  only one copy of the field in memory B)  a copy of the field for each method in the class C)  two reference copies of the field for each method in the class D)  a copy of the field in each class object on To compare two objects in a class, ________. Question options: A)  use the  ==  operator (for example,  object1 == object2 ) B)  write a method to do a byte-by-byte compare of the two objects C)  write an  equals  method that will make a field by field compare of the two objects
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
D)  This cannot be done since objects consist of several fields. on Which of the following is  not  true about static methods? Question options: A)  They are called directly from the class. B)  They are often used to create utility classes that perform operations on data but have no need to store and collect data. C)  They are created by placing the key word  static  after the access specifier in the method header. D)  It is necessary for an instance of the class to be created to execute the method. on If you attempt to perform an operation with a null reference variable ________. Question options: A)  the program will terminate t B)  the resulting operation will always be zero ct C)  Java will create an object to reference the variable t D)  the results will be unpredictable on If  object1  and  object2  are objects of the same class, to make  object2  a copy of  object1  ________. Question options: A)  use the default constructor to create  object2  with  object1  data members B)  use the  copy  method that is a part of the Java language C)  use an assignment statement to make  object2  a copy of  object1
D)  write a method for the class that will make a field by field copy of  object1  data members into  object2  data on If you have defined a class,  SavingsAccount , with a public  static  method,  getNumberOfAccounts , and created SavingsAccount  object referenced by the variable  account20 , which of the following will call the  getNumberOfAccounts  method? Question options: A)  SavingsAccount.getNumberOfAccounts(); B)  getNumberOfAccounts(); C)  SavingsAccount.account20.getNumberOfAccounts(); D)  account20.getNumberOfAccounts(); on If you have defined a class,  SavingsAccount , with a public  static  data member named  numberOfAccounts , and created a  SavingsAccount  object referenced by the variable  account20 , which of the following will assign  numberOfAccounts  to  numAccounts ? Question options: A)  numAccounts = account20.numAccounts; B)  numAccounts = account20; C)  numAccounts = numOfAccounts; D)  numAccounts = SavingsAccount.numberOfAccounts; on Assume the class  BankAccount  has been created and the following statement correctly creates an instance of the class.
BankAccount account = new BankAccount(5000.00); What is true about the following statement? System.out.println(account); Question options: A)  A runtime error will occur. B)  The method will display unreadable binary data on the screen. C)  The  account  object's  toString  method will be implicitly called. D)  A compiler error will occur. on Given the following method header, what will be returned from the method? public Rectangle getRectangle() Question options: incorrec t A)  an object of the class  Rectangle incorrect B)  a graph of a rectangle incorrect C)  the values stored in the data members of the  Rectangle   object correct D) the address of an object of the Rectangle class
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