What will be returned from a method, if the following is the method header? publ
ID: 3836192 • Letter: W
Question
What will be returned from a method, if the following is the method header? public Rectangle getRectangle() a An object of the class Rectangle b The address of an object of the class Rectangle c The values stored in the data members of the Rectangle object the method changed d A graph of a rectangle If you have defined a class SavingsAccount with a public static method getNumberOfAccounts(), and created a SavingsAccount object referenced by the variable account 20, which of the following will call the getNumberOfAccounts()method? a getNumberOfAccounts(); b Savings Account getNumberOfAccounts(); c getNumberOfAccounts (account20); d None of the above, you cannot call a static method. If object1 and object2 are objects of the same class, to make object2 a copy of object1: a assign object1 to object2, such as object2 = object 1; b write a copy method that will make a field by field copy of object1 data members into object2 data members c use the Java copy method that is a part of the Java language d use the default constructor to create object2 with object1 data members When a method's return type is a class, what is actually returned to the calling program? a An object of that class b A reference to an object of that class c Only the values in the object that the method accessed d Nothing, the return type is strictly for documentation in this situation Which of the following is not true about static methods? a It is not necessary for an instance of the class to be created to execute the method. b They are created by placing the key word static after the access specifier in the method header. c They are called from an instance of the class. d They are often used to create utility classes that perform operations on data, but have no need to collect and store data.Explanation / Answer
25. public Rectangle getRectangle()
Answer:b
in this getRectangle is the name of function and Rectangle is the return type
of function, that is object of class rectangle. So it will retuen the address
of an object of the class Rectangle.
26. Answer:b
As static method doesnot needobject refrence they can be called by directly
classname.method name.
So, SavingAccount.getNumberOfAccounts() is correct.
27.Answer:a
object in java are the refrences that points to instance of class.
when you do object2=object1,Object2 also starts pointing to same instance
of class.in this way we are actually assigning the value of the reference
object1 to object2
28.Answer:b
method will return the refrence to an object of that class.
29.Answer:c
static methods are called diretly from class they do not need instance of class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.