Class level identifiers have what scope? Write an enhanced for loop to iterate t
ID: 3789938 • Letter: C
Question
Class level identifiers have what scope? Write an enhanced for loop to iterate through all elements in an array of type doubles and add their value. The array is named numbers? Write a header for a constructor for the Date class below. The constructor has three arguments and the class is described below: public class Date {private int month;//1-12 private int day;//1-31 based on month public int Year//constructor: use properly Month to confirm proper value for month;//use property Day to confirm proper value for day.} Date date - new Date(month day, Year); Which members of a class are usually declared private?Explanation / Answer
48. Class level identifier is visible and accessible every where in class.
49.
double sum;
for(int i = 0; i < numbers.length; i++)
{
sum += numbers[i];
}
50.
public class Date {
private int month; // 1-12
private int day; // 1-31 based on month
public int Year;
/**
* Create a date object
* @param month Month of the date
* @param day day of the date
* @param year year of the date
*/
public Date(int month, int day, int year)
{
this.month = month;
this.day = day;
this.Year = year;
}
}
51.
Members whose variable shouldn't be changed by anywhere apart from class i.e.., whose data needs to be safegaurd needs to be private.