When should you make a method static? Can static methods access object data?

What will be an ideal response?


When the method doesn't operate on a current object. No, static methods are not passed a current object so they don't have access to object data.

Computer Science & Information Technology

You might also like to view...

What is the output of the following program?

``` public class Test { public static void main(String[] args) { int[][] values = {{3, 4, 5, 1}, {33, 6, 1, 2}}; for (int row = 0; row < values.length; row++) { System.out.print(m(values[row]) + " "); } } public static int m(int[] list) { int v = list[0]; for (int i = 1; i < list.length; i++) if (v < list[i]) v = list[i]; return v; } } ``` a. 3 33 b. 1 1 c. 5 6 d. 5 33 e. 33 5

Computer Science & Information Technology

Mastery is defined as ________

A) feeling confident and excited about learning new skills B) working for something larger C) working without continual direction and control D) combining leisure time with the tools to be creative

Computer Science & Information Technology

PNG uses lossy compression.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A ____ is a prewritten formula that is built into Excel.

A. function B. feature C. task D. calculation

Computer Science & Information Technology