Question
1. Write a statement that will declare a two dimensional Integer array with 7 rows and 5 columns (10 pts). 2. Using the array above,
1. Write a statement that will declare a two dimensional Integer array with 7 rows and 5 columns (10 pts).
2. Using the array above, write the code fragment that will initialize your array row by row from left to right beginning with the number 1 (1, 2, 3, 4, 5,6,7,8,9,10. etc). Use nested for loop. Do not hard code values nor loop control variable (20 pts).
public static void main(String[] args) { }
3. Write a java method called avgArray which takes as its parameters an int array and its size and returns the average of all the array elements and returns the same. (20 pts)
4. Mark the statements as TRUE or FALSE (5 pts)
- The methods of a class must be public.
- A constructor can have a value of int type.
- A class can have more than one constructor.
- Method definitions can be nested.
- A method of a class that modifies the values of the data members is called Accessor method.
5. Write the default constructor for the below class (15 pts)
class Student { private String name; private int age; private String address;
}
6. Given the following code (10 pts)
public class Mystery { private int x; private double y;
public void print()
{
System.out.println(x+ +y););
}
public int sum()
{
return x+y;
}
}
- What is the name of the class?
- What are the instance variables?
- What are the methods?
- what are the private members?
- what are the public members?
7. Using the class described in question6, Mystery (20 pts)
a. Write a java statement to instantiate an object called unknown.
b. Write a java statements to access methods using the object that was created in 7a.
1. Write a statement that will declare a two dimensional Integer array with 7 rows and 5 columns (10 pts).
2. Using the array above, write the code fragment that will initialize your array row by row from left to right beginning with the number 1 (1, 2, 3, 4, 5,6,7,8,9,10. etc). Use nested for loop. Do not hard code values nor loop control variable (20 pts).
public static void main(String[] args) {
}
3. Write a java method called avgArray which takes as its parameters an int array and its size and returns the average of all the array elements and returns the same. (20 pts)
4. Mark the statements as TRUE or FALSE (5 pts)
- The methods of a class must be public.
- A constructor can have a value of int type.
- A class can have more than one constructor.
- Method definitions can be nested.
- A method of a class that modifies the values of the data members is called Accessor method.
- 5. Write the default constructor for the below class (15 pts)
class Student { private String name; private int age; private String address;
}
6. Given the following code (10 pts)
public class Mystery { private int x; private double y;
public void print()
{
System.out.println(x+ +y););
}
public int sum()
{
return x+y;
}
}
- What is the name of the class?
- What are the instance variables?
- What are the methods?
- what are the private members?
- what are the public members?
7. Using the class described in question6, Mystery (20 pts)
a. Write a java statement to instantiate an object called unknown.
b. Write a java statements to access methods using the object that was created in 7a.
1. Write a statement that will declare a two dimensional Integer array with 7 rows and 5 columns (10 pts).
2. Using the array above, write the code fragment that will initialize your array row by row from left to right beginning with the number 1 (1, 2, 3, 4, 5,6,7,8,9,10. etc). Use nested for loop. Do not hard code values nor loop control variable (20 pts).
public static void main(String[] args) {
}
3. Write a java method called avgArray which takes as its parameters an int array and its size and returns the average of all the array elements and returns the same. (20 pts)
4. Mark the statements as TRUE or FALSE (5 pts)
- The methods of a class must be public.
- A constructor can have a value of int type.
- A class can have more than one constructor.
- Method definitions can be nested.
- A method of a class that modifies the values of the data members is called Accessor method.
5. Write the default constructor for the below class (15 pts)
class Student { private String name; private int age; private String address;
}
6. Given the following code (10 pts)
public class Mystery { private int x; private double y;
public void print()
{
System.out.println(x+ +y););
}
public int sum()
{
return x+y;
}
}
- What is the name of the class?
- What are the instance variables?
- What are the methods?
- what are the private members?
- what are the public members?
7. Using the class described in question6, Mystery (20 pts)
a. Write a java statement to instantiate an object called unknown.
b. Write a java statements to access methods using the object that was created in 7a.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started