Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) If I write a class named Worker with a static field named workerNum, and then

ID: 665692 • Letter: 1

Question


1) If I write a class named Worker with a static field named workerNum, and then create 10 objects of type Worker, how many workerNums are created?


2) A static class member belongs to the ______ and not an __________ of the class.

3) Must all static class members be declared with public access?


4) Look at the documentation from the Java Character class:

static boolean isDigit(char ch)
Determines if the specified character is a digit.Write the line of code to determine if the value stored in the variable sym is a digit.     

5) Why is main( ) declared as static?

6) Why can't static methods access non-static fields?

1) Declare an array to hold 50 double values.

2) What is the value of each of the elements you declared above?

3) Loop through the array and assign a random double to each element of the array.


4) Loop through the array and print each value in the array.


5) Loop through the array and print the values of the array in reverse order.

6) Declare a new array with 100 elements and assign the values of the first array to this new array.
Then rename this new array to the name of the original array.

Explanation / Answer

1.
Only 1, because static objects belong to a class, not any object of the class

2.
A static class member belongs to the class and not an object of the class.

3.
Not necessarily, they may be private or protected.

4.
static boolean isDigit(char ch){
   if(ch >= '0' && ch <= '9') return true;
   else return false;
}

5.
Because the execution of a program has to start with main(), and there is no object in the very beginning which can call the main method.