A. 1 and 2 B. 2 and 4 C. 3 and 4 D. 1 and 3 Answer: Option B Which of the following statements regarding static methods are correct?
1. Static methods are difficult to maintain, because you can not change their implementation.
2. Static methods can be called using an object reference to an object of the class in which this method is defined.
3. Static methods are always public, because they are defined at class-level.
4. Static methods do not have direct access to non-static methods which are defined inside
the same class.
Join The Discussion
Related Questions on Constructors and Methods
Which of the following statements are incorrect?
[a] static methods can call other static methods only
[b] static methods must only access static data
[c] static methods can not refer to this or super in any way
[d] when object of class is declared, each object contains its own copy of static variables
This question was addressed to me in my homework.
This intriguing question originated from Arrays Revisited & Keyword static in portion Classes and Methods of Java
4. Which of the following statements are incorrect?a] static methods can call other static methods only
We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Expert Verified
b] static methods must only access static datac] static methods can not refer to this or super in any wayd] when object of class is declared, each object contains its own copy of static variablesView AnswerAnswer: dExplanation: All objects of class share same static variable, when object of a class are declared, all theobjects share same copy of static members, no copy of static variables are made.5. Which of the following statements are incorrect?View Answer
Get answer to your question and much more
Explanation: None.6. Which of these methods must be made static?View Answer
Get answer to your question and much more
7. What is the output of this program?{;;]{a;b;}}{
Get answer to your question and much more
14.15.access obj1=newaccess[]16.access obj2=newaccess[]17.obj1.x=18.obj1.y=19.obj1.cal[1,2]20.obj2.x=21.obj2.cal[2,3]22.System.out.println[obj1.x+" "+obj2.23.24.{;;0;0;;0;;y];}}a] 1 2b] 2 3c] 3 2d] 1 5Answer: dExplanation: None.output:$ javac static_specifier.java$ java static_specifier1 5View Answer
8. What is the output of this program?{;{
Get answer to your question and much more
7.}8.}9.classstatic_use10.{11.publicstaticvoidmain[Stringargs[]]12.{13.access obj1=newaccess[];14.access obj2=newaccess[];15.obj1.x=0;16.obj1.increment[];17.obj2.increment[];18.System.out.println[obj1.x+" "+obj2.x];
Get answer to your question and much more
9. What is the output of this program?{;;]
Get answer to your question and much more
6.{7.x=a+b;8.y=x+b;9.}10.}11.classstatic_use12.{13.publicstaticvoidmain[Stringargs[]]14.{15.static_out obj1=newstatic_out[];16.static_out obj2=newstatic_out[];17.inta=2;18.obj1.add[a, a+1];19.obj2.add[5, a];20.System.out.println[obj1.x+" "+obj2.y];21.}22.}a] 7 7b] 6 6
Get answer to your question and much more
Upload your study docs or become a
Course Hero member to access this document
Upload your study docs or become a
Course Hero member to access this document