2 bbhosted.cuny.edu -Google Sea. Take Test Quiz.. (29 QUESTION 1 Which of the fo
ID: 3735376 • Letter: 2
Question
2 bbhosted.cuny.edu -Google Sea. Take Test Quiz.. (29 QUESTION 1 Which of the following is NOT true about static methods? O It is necessary for an instance of the class to be created to execute the method. O They are created by placing the key word static after the access specifier in the method header O They are often used to create utility classes that perform operations on data, but have no need to collect and store data. O They are called directly from the class. QUESTION 2 Look at the folowing declaration: enum Tree OAK, MAPLE, PINE What is the ordinal value of the MAPLE enum constant? 0 1 Tree.MAPLE QUESTION 3 Assume the class BankAccount has been created, and the following statement correctly creates an instance of the class: BankAccount account - new BankAccount (s5000.0) What is TRUE about the following statement? System.out.printin (accoun) A runtime error will occur A compiler error will occur The account object's tostring method will be implicity caled The method will display unreadable binary data on the screenExplanation / Answer
ANSWER 1: it is necessary for an instance of the class to be created to execute the method.
EXPLANATION: Static members of a class are properties of the class, unlike instances members. Static properties are shared among the instances of the class. In order to access static properties of a class the syntax is: Classname.method() or Classname.variable.
ANSWER 2: 1
EXPLANATION: In Java Enums start with 0.
ANSWER 3: The account object's toString() method will be implicitly called.
EXPLANATION: In JAVA everything inherits from Object class, so the toString() on Object will be called if you have not defined one. So, System.out.println(account); implicitly calls it.
ANSWER 4: has a
EXPLANATION: Aggregation is a special form of association. It represents a HAS-A relationship.
ANSWER 5: It must be the first statement in the constructor making the call.
EXPLANATION: The parent class's constructor must be called before the subclass's constructor. It ensures that if any methods are invoked on the parent class in the constructor, the parent class has already been set up correctly.
ANSWER 6: An object of the Rectangle class
EXPLANATION: As shown by the method return type.
ANSWER 7: Question is incomplete as the TYPE of static member variable has not been mentioned in the question. However, the following are the default values for their respective types:
Numbers: 0
Objects: null
Boolean: false
ANSWER 8: numAccounts = SavingsAccount.numberOfAccounts
EXPLANATION: Static members are accessed via Classname.member
ANSWER 9: Ordinal
EXPLANATION: It is part of the language specification.
ANSWER 10: Objects
EXPLANATION: In order to compare the contents of an Object one needs to use the equals() method.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.